ModelConfig
extends Base
in package
Model configuration class, a formal definition of a Repository model.
Table of Contents
- $backend : string
- The identfier of the backend this config belongs to.
- $backendConfig : mixed
- An container for RepositoryBackend specific settings.
- $belongsTo : array<string|int, mixed>
- Configuration of the belongsTo relation(s).
- $class : string|null|false
- The full classname (null: AutoDetect class, false: Autogenerate class).
- $defaults : array<string|int, mixed>
- Default values for new instance.
- $hasMany : array<string|int, mixed>
- Configuration of the hasMany relation(s) Contains both one-to-many and many-to-many relations.
- $id : array<string|int, mixed>
- The element(s) in the backend data that identifies an instance. Example: array('id') for the 'id' field.
- $ignoreProperties : array<string|int, mixed>
- A whitelist of (public) properties that won't be listed as missing when validation the class.
- $name : string
- The name of the model.
- $plural : string
- The name of the model in plural from.
- $properties : array<string|int, mixed>
- Direct mapping of properties to the backend data structure. array($column => $property).
- $readFilters : array<string|int, mixed>
- Filter the data from the backend before using setting the values in the instance.
- $writeFilters : array<string|int, mixed>
- Filter the property values before writing the data to the backend.
- __call() : mixed
- Report that the $method doesn't exist.
- __callStatic() : mixed
- Report that the $method doesn't exist.
- __construct() : mixed
- Constructor.
- __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.
- getPropertyNames() : array<string|int, mixed>
- Return all property-paths.
Properties
$backend
The identfier of the backend this config belongs to.
public
string
$backend
$backendConfig
An container for RepositoryBackend specific settings.
public
mixed
$backendConfig
This is the config that is passed to create, read, update and delete functions in the backend.
$belongsTo
Configuration of the belongsTo relation(s).
public
array<string|int, mixed>
$belongsTo
= []
[$property => [ 'reference' => $column, // foreign_key: "product_id" 'model' => $modelName, // The foreign model: "Product" 'id' => $column, // (optional) The id: "id" ], $property => [ 'convert' => $column, // column with data: array('id' => 1, 'name' => 'James Bond') 'model' => $modelName, // The model: "Hero" ]]
$class
The full classname (null: AutoDetect class, false: Autogenerate class).
public
string|null|false
$class
$defaults
Default values for new instance.
public
array<string|int, mixed>
$defaults
= []
'property(PropertyPath)' => default value
$hasMany
Configuration of the hasMany relation(s) Contains both one-to-many and many-to-many relations.
public
array<string|int, mixed>
$hasMany
= []
[$property => [ 'model' => $modelName, // The foreign model: "Product" 'reference' => $column, // foreign_key to this container instance. 'conditions' => [] // (optional) Additional extra (static) conditions // For 1 to many: 'belongsTo' => $propertyPath, // (optional) The belongsTo property in the related instances in a one-to-many relation that refers back to the container instance. Used in save() for implicitly setting the foreignkey value. // For many to many 'through' => $junctionName, // (optional) The junction for many-to-many relations. 'junctionClass' => $fullclassname, // (optional) The junctionClass to use (defaults to the Sledgehammer\Junction) 'fields' => [$column => $junctionProperty], // (optional) Mapping for the additional fields in a junction (many-to-many with fields) 'id' => $column, // (optional) foreign_key for the related model in the many-to-many table: "product_id" ]]
$id
The element(s) in the backend data that identifies an instance. Example: array('id') for the 'id' field.
public
array<string|int, mixed>
$id
= []
$ignoreProperties
A whitelist of (public) properties that won't be listed as missing when validation the class.
public
array<string|int, mixed>
$ignoreProperties
= []
$name
The name of the model.
public
string
$name
$plural
The name of the model in plural from.
public
string
$plural
$properties
Direct mapping of properties to the backend data structure. array($column => $property).
public
array<string|int, mixed>
$properties
= []
$readFilters
Filter the data from the backend before using setting the values in the instance.
public
array<string|int, mixed>
$readFilters
= []
'column(PropertyPath)' => filter(callable)
$writeFilters
Filter the property values before writing the data to the backend.
public
array<string|int, mixed>
$writeFilters
= []
'column(PropertyPath)' => filter(callable)
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 —__construct()
Constructor.
public
__construct(string $name[, array<string|int, mixed> $options = [] ]) : mixed
Parameters
- $name : string
-
Model name
- $options : array<string|int, mixed> = []
-
Additional configuration options
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 —getPropertyNames()
Return all property-paths.
public
getPropertyNames() : array<string|int, mixed>