An abstract class that implements most of ModelInterface
.
In addition to ModelInterface
, the abstract model implements the following interfaces:
DescribableInterface
- `StorableInterface
ValidatableInterface
ViewableInterface
.
Those interfaces
are implemented (in parts, at least) with the DescribableTrait
, StorableTrait
,
ValidatableTrait
and the ViewableTrait
.
The JsonSerializable
interface is fully provided by the DescribableTrait
.
Methods summary
public
|
|
public
|
#
setDependencies( Pimple\Container $container )
Inject dependencies from a DI Container.
Inject dependencies from a DI Container.
Parameters
- $container
- A dependencies container instance.
|
protected
array|Traversable
|
#
setIdFromData( array|Traversable $data )
Set the object's ID from an associative array map (or any other Traversable).
Set the object's ID from an associative array map (or any other Traversable).
Useful for setting the object ID before the rest of the object's data.
Parameters
Returns
array|Traversable The object data without the pre-set ID.
|
public
Charcoal\Model\AbstractModel
|
#
setData( array $data )
Sets the object data, from an associative array map (or any other Traversable).
Sets the object data, from an associative array map (or any other Traversable).
Parameters
- $data
- The entity data. Will call setters.
Returns
Implementation of
|
public
array
|
#
data( array $propertyFilters = null )
Return the object data as an array.
Return the object data as an array.
Parameters
- $propertyFilters
- Optional. Property filter.
Returns
array
Implementation of
|
public
EntityInterface
|
#
mergeData( array|Traversable $data )
Override's \Charcoal\Config\AbstractEntity 's setData method to take properties into consideration.
Override's \Charcoal\Config\AbstractEntity 's setData method to take properties into consideration.
Also add a special case, to merge values for l10n properties.
Parameters
Returns
EntityInterface Chainable
See
\Charcoal\Config\AbstractEntity::offsetSet()
|
public
array
|
|
public
Charcoal\Model\AbstractModel
|
#
setFlatData( array $flatData )
Sets the data
This function takes a 1-dimensional array and fill the object with its value.
Parameters
- $flatData
- The data, as a flat (1-dimension) array.
Returns
Implementation of
|
public
array
|
#
flatData( )
Returns
array
Implementation of
|
public
mixed
|
#
propertyValue( string $propertyIdent )
Parameters
- $propertyIdent
- The property ident to get the value from.
Returns
mixed
|
public
boolean
|
#
saveProperties( array $properties = null )
Parameters
- $properties
- Optional array of properties to save. If null, use all object's properties.
Returns
boolean
|
public
string
|
#
loadFromL10n( string $key, mixed $value, array $langs )
Load an object from the database from its l10n key $key.
Also retrieve and return the actual language that matched.
Load an object from the database from its l10n key $key.
Also retrieve and return the actual language that matched.
Parameters
- $key
- Key pointing a column's l10n base ident.
- $value
- Value to search in all languages.
- $langs
- List of languages (code, ex: "en") to check into.
Returns
string The matching language.
Throws
Exception If the PDO query fails.
|
public
boolean
|
#
save( )
Save the object's current state to storage.
Save the object's current state to storage.
Overrides default StorableTrait save() method to also save properties.
Returns
boolean
See
Charcoal\Source\StorableTrait::save() For the "create" event.
Implementation of
|
protected
boolean
|
#
preSave( )
StorableTrait > preSave(). Save hook called before saving the model.
StorableTrait > preSave(). Save hook called before saving the model.
Returns
boolean
|
protected
boolean
|
#
preUpdate( array $properties = null )
StorableTrait > preUpdate(). Update hook called before updating the model.
StorableTrait > preUpdate(). Update hook called before updating the model.
Parameters
- $properties
- Optional. The properties to update.
Returns
boolean
|
protected
Charcoal\Model\MetadataInterface
|
#
createMetadata( )
DescribableTrait > createMetadata().
DescribableTrait > createMetadata().
Returns
|
protected
SourceInterface
|
#
createSource( )
StorableInterface > createSource()
StorableInterface > createSource()
Returns
SourceInterface
Throws
Exception If the metadata source can not be found.
|
protected
ValidatorInterface
|
#
createValidator( array $data = null )
ValidatableInterface > create_validator().
ValidatableInterface > create_validator().
Parameters
Returns
ValidatorInterface
|
public
ViewInterface
|
#
createView( array $data = null )
Parameters
- $data
- Optional. View data.
Returns
ViewInterface
|
public
string
|
#
objType( )
Convert the current class name in "type-ident" format.
Convert the current class name in "type-ident" format.
Returns
string
|