ModelBehavior
extends RepositoryBackend
in package
Overwrite the behavior for models. Sits bewteen the RepositoryBackend and the Repository.
Table of Contents
- $backend : RepositoryBackend
- $configs : array<string|int, ModelConfig>
- The available models in this backend.
- $identifier : string
- $junctions : array<string|int, mixed>|ModelConfig
- The junction tables.
- __call() : mixed
- Report that the $method doesn't exist.
- __callStatic() : mixed
- Report that the $method doesn't exist.
- __get() : mixed
- Report that $property doesn't exist.
- __set() : mixed
- Report that $property doesn't exist and set the property to the given $value.
- __toString() : string
- The object is used as an string.
- add() : mixed
- Add a new record.
- all() : Traversable|array<string|int, mixed>
- Retrieve all available model-data.
- delete() : mixed
- Permanently remove an record based on the data.
- get() : mixed
- Retrieve model-data by id.
- register() : mixed
- Callback for when Repository->registerBehavior is called.
- related() : Traversable|array<string|int, mixed>
- Retrieve all related model-data.
- renameModel() : mixed
- Rename a model and remap the relations to the new name.
- renameProperty() : mixed
- Rename a property and remap the relations to the new name.
- skipProperty() : mixed
- Remove a property.
- update() : mixed
- Update an existing record.
Properties
$backend
public
RepositoryBackend
$backend
$configs
The available models in this backend.
public
array<string|int, ModelConfig>
$configs
array('Model name' => ModelConfig, 'Model2 name' => ModelConfig, ...)
$identifier
public
string
$identifier
$junctions
The junction tables.
public
array<string|int, mixed>|ModelConfig
$junctions
= []
Methods
__call()
Report that the $method doesn't exist.
public
__call(string $method, array<string|int, mixed> $arguments) : mixed
Parameters
- $method : string
- $arguments : array<string|int, mixed>
Return values
mixed —__callStatic()
Report that the $method doesn't exist.
public
static __callStatic(string $method, array<string|int, mixed> $arguments) : mixed
Parameters
- $method : string
- $arguments : array<string|int, mixed>
Return values
mixed —__get()
Report that $property doesn't exist.
public
__get(string $property) : mixed
Parameters
- $property : string
Return values
mixed —__set()
Report that $property doesn't exist and set the property to the given $value.
public
__set(string $property, mixed $value) : mixed
Parameters
- $property : string
- $value : mixed
Return values
mixed —__toString()
The object is used as an string.
public
__toString() : string
Return values
string —add()
Add a new record.
public
add(mixed $data, array<string|int, mixed> $config) : mixed
Parameters
- $data : mixed
- $config : array<string|int, mixed>
Return values
mixed —all()
Retrieve all available model-data.
public
all(array<string|int, mixed> $config) : Traversable|array<string|int, mixed>
Parameters
- $config : array<string|int, mixed>
Return values
Traversable|array<string|int, mixed> —delete()
Permanently remove an record based on the data.
public
delete(array<string|int, mixed> $data, array<string|int, mixed> $config) : mixed
Parameters
- $data : array<string|int, mixed>
-
Might only contain the ID
- $config : array<string|int, mixed>
Return values
mixed —get()
Retrieve model-data by id.
public
get(mixed $id, mixed $config) : mixed
Parameters
- $id : mixed
- $config : mixed
Return values
mixed —data
register()
Callback for when Repository->registerBehavior is called.
public
register(ModelConfig $config) : mixed
Allows modification of the config.
Parameters
- $config : ModelConfig
Return values
mixed —related()
Retrieve all related model-data.
public
related(mixed $config, mixed $reference, mixed $id) : Traversable|array<string|int, mixed>
Parameters
- $config : mixed
- $reference : mixed
- $id : mixed
-
The ID of the container instance.
Return values
Traversable|array<string|int, mixed> —renameModel()
Rename a model and remap the relations to the new name.
public
renameModel(string $from, string $to) : mixed
Parameters
- $from : string
-
Current name
- $to : string
-
The new name
Return values
mixed —renameProperty()
Rename a property and remap the relations to the new name.
public
renameProperty(string $model, string $from, string $to) : mixed
Parameters
- $model : string
-
The modelname
- $from : string
-
The current propertyname
- $to : string
-
The new propertyname
Return values
mixed —skipProperty()
Remove a property.
public
skipProperty(string $model, string $property) : mixed
Parameters
- $model : string
-
The modelname
- $property : string
-
The current propertyname
Return values
mixed —update()
Update an existing record.
public
update(mixed $new, mixed $old, array<string|int, mixed> $config) : mixed
Parameters
- $new : mixed
- $old : mixed
- $config : array<string|int, mixed>
Return values
mixed —updated data