Property | Type | Description | |
---|---|---|---|
$_autoConfig | array | Auto configuration. | |
$_data | array | Associative array of the entity's fields and values. | |
$_errors | array | The list of validation errors associated with this object, where keys are field names, and values are arrays containing one or more validation error messages. | |
$_exists | boolean | A flag indicating whether or not this entity exists. Set to false if this is a newly-created entity, or if this entity has been loaded and subsequently deleted. Set to true if the entity has been loaded from the database, or has been created and subsequently saved. | |
$_handlers | array | Hold the "data export" handlers where the keys are fully-namespaced class names, and the values are closures that take an instance of the class as a parameter, and return an array or scalar value that the instance represents. | |
$_increment | array | An array of key/value pairs corresponding to fields that should be updated using atomic incrementing / decrementing operations. Keys match field names, and values indicate the value each field should be incremented or decremented by. | |
$_model | string | Fully-namespaced class name of model that this record is bound to. Instance methods declared in the model may be called on the entity. See the Model class documentation for more information. | |
$_parent | object | If this record is chained off of another, contains the origin object. | |
$_relationships | array | An array containing all related records and recordsets, keyed by relationship name, as defined in the bound model class. | |
$_schema | array | to create a form. | |
$_updated | array | Contains the values of updated fields. These values will be persisted to the backend data store when the document is saved. |
Method | Description | |
---|---|---|
__call ( string $method, array $params ) : mixed | Magic method that allows calling of model methods on this record instance, i.e.: $record->validates(); | |
__construct ( array $config = [] ) : void | Constructor. | |
__get ( string $name ) : mixed | Overloading for reading inaccessible properties. | |
__isset ( string $name ) : mixed | Overloading for calling isset() or empty() on inaccessible properties. | |
__set ( string $name, mixed $value ) : void | PHP magic method used when setting properties on the Entity instance, i.e. | |
__toString ( ) : string | Returns a string representation of the Entity instance, based on the result of the 'title' meta value of the bound model class. | |
assignTo ( object $parent, array $config = [] ) | Configures protected properties of an Entity so that it is parented to $parent. | |
data ( string $name = null ) : mixed | Access the data fields of the record. Can also access a $named field. | |
decrement ( string $field, string $value = 1 ) : integer | Decrements a field by the specified value. Works identically to increment(), but in reverse. | |
errors ( array | string $field = null, string $value = null ) : mixed | Access the errors of the record. | |
exists ( ) : boolean | A flag indicating whether or not this record exists. | |
export ( array $options = [] ) | ||
increment ( string $field, integer | string $value = 1 ) : integer | Safely (atomically) increments the value of the specified field by an arbitrary value. | |
model ( ) : string | Returns the model which this entity is bound to. | |
modified ( $field = null ) : mixed | Gets the current state for a given field or, if no field is given, gets the array of fields modified on this entity. | |
parent ( ) : object | Returns the parent object of this object, if any. | |
respondsTo ( string $method, boolean $internal = false ) : boolean | Determines if a given method can be called. | |
schema ( $field = null ) | ||
serialize ( ) : string | Prepares, enables and executes serialization of the object. | |
set ( array $data ) : void | Allows several properties to be assigned at once, i.e.: $record->set(array('title' => 'Lorem Ipsum', 'value' => 42)); | |
sync ( mixed $id = null, array $data = [], array $options = [] ) | Called after an Entity is saved. Updates the object's internal state to reflect the corresponding database entity, and sets the Entity object's key, if this is a newly-created object. **Do not** call this method if you intend to update the database's copy of the entity. Instead, see Model::save(). | |
to ( string $format, array $options = [] ) : mixed | Converts the data in the record set to a different format, i.e. an array. | |
unserialize ( string $data ) : void | Prepares, enables and executes unserialization of the object. |
Method | Description | |
---|---|---|
_init ( ) |
public __construct ( array $config = [] ) : void | ||
$config | array | Available configuration options are: - `'data'` _array_: Data to enter into the record. Defaults to an empty array. - `'model'` _string_: Class name that provides the data-source for this record. Defaults to `null`. |
return | void |
public __toString ( ) : string | ||
return | string | Returns the generated title of the object. |
public errors ( array | string $field = null, string $value = null ) : mixed | ||
$field | array | string | If an array, overwrites `$this->_errors` if it is empty, if not, merges the errors with the current values. If a string, and `$value` is not `null`, sets the corresponding key in `$this->_errors` to `$value`. Setting `$field` to `false` will reset the current state. |
$value | string | Value to set. |
return | mixed | Either the `$this->_errors` array, or single value from it. |
public increment ( string $field, integer | string $value = 1 ) : integer | ||
$field | string | The name of the field to be incremented. |
$value | integer | string | The value to increment the field by. Defaults to `1` if this parameter is not specified. |
return | integer | Returns the current value of `$field`, based on the value retrieved from the data source when the entity was loaded, plus any increments applied. Note that it may not reflect the most current value in the persistent backend data source. |
public respondsTo ( string $method, boolean $internal = false ) : boolean | ||
$method | string | Name of the method. |
$internal | boolean | Provide `true` to perform check from inside the class/object. When `false` checks also for public visibility; defaults to `false`. |
return | boolean | Returns `true` if the method can be called, `false` otherwise. |
public sync ( mixed $id = null, array $data = [], array $options = [] ) | ||
$id | mixed | The ID to assign, where applicable. |
$data | array | Any additional generated data assigned to the object by the database. |
$options | array | Method options: - `'materialize'` _boolean_: Determines whether or not the flag should be set that indicates that this entity exists in the data store. Defaults to `true`. - `'dematerialize'` _boolean_: If set to `true`, indicates that this entity has been deleted from the data store and no longer exists. Defaults to `false`. |
public to ( string $format, array $options = [] ) : mixed | ||
$format | string | Currently only `array`. |
$options | array | Options for converting: - `'indexed'` _boolean_: Allows to control how converted data of nested collections is keyed. When set to `true` will force indexed conversion of nested collection data. By default `false` which will only index the root level. |
return | mixed |
public unserialize ( string $data ) : void | ||
$data | string | Serialized properties of the object. |
return | void |
protected array $_data | ||
return | array |
protected array $_errors | ||
return | array |
protected bool $_exists | ||
return | boolean |
protected array $_handlers | ||
return | array |
protected array $_increment | ||
return | array |
protected string $_model | ||
return | string |
protected object $_parent | ||
return | object |
protected array $_relationships | ||
return | array |
protected array $_updated | ||
return | array |