DEFAULT_SOURCE_TYPE
DEFAULT_SOURCE_TYPE
An abstract class that implements most of `ModelInterface`.
In addition to ModelInterface
, the abstract model implements the following interfaces:
DescribableInterface
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
.
$metadataLoader : \Charcoal\Model\Service\MetadataLoader
$metadata : \Charcoal\Model\MetadataInterface
$validator : \Charcoal\Validator\ValidatorInterface
In-objet copy of the `ValidatorInterface` validator object
$source : \Charcoal\Source\SourceInterface
setData(array $data) : \Charcoal\Model\AbstractModel
Sets the object data, from an associative array map (or any other Traversable).
array | $data | The entity data. Will call setters. |
Chainable
setMetadataLoader(\Charcoal\Model\Service\MetadataLoader $loader) : \Charcoal\Model\DescribableInterface
\Charcoal\Model\Service\MetadataLoader | $loader | The loader instance, used to load metadata. |
Chainable
setMetadata(array|\Charcoal\Model\MetadataInterface $metadata) : \Charcoal\Model\DescribableInterface
array|\Charcoal\Model\MetadataInterface | $metadata | The object's metadata. |
If the parameter is not an array or MetadataInterface.
Chainable
metadata() : \Charcoal\Model\MetadataInterface
loadMetadata(string $metadataIdent = null) : \Charcoal\Model\MetadataInterface
Load a metadata file and store it as a static var.
Use a MetadataLoader
object and the object's metadataIdent
to load the metadata content (typically from the filesystem, as json).
string | $metadataIdent | Optional ident. |
setMetadataIdent(string $metadataIdent) : \Charcoal\Model\DescribableInterface
string | $metadataIdent | The metadata ident. |
Chainable
setId(mixed $id) : \Charcoal\Source\StorableInterface
Set the object's ID. The actual property set depends on `key()`
mixed | $id | The object id (identifier / primary key value). |
If the argument is not scalar.
Chainable
setKey(string $key) : \Charcoal\Source\StorableInterface
Set the key property.
string | $key | The object key, or identifier "name". |
If the argument is not scalar.
Chainable
setSource(\Charcoal\Source\SourceInterface $source) : \Charcoal\Source\StorableInterface
Set the object's source.
\Charcoal\Source\SourceInterface | $source | The storable object's source. |
Chainable
source() : \Charcoal\Source\SourceInterface
Get the object's source.
load(mixed $id = null) : \Charcoal\Source\StorableInterface
Load an object from the database from its ID.
mixed | $id | The identifier to load. |
Chainable
loadFrom(string $key = null, mixed $value = null) : \Charcoal\Source\StorableInterface
Load an object from the database from its key $key.
string | $key | Key pointing a column's name. |
mixed | $value | Value of said column. |
Chainable.
loadFromQuery(string $query, array $binds = array()) : \Charcoal\Source\StorableInterface
Load an object from the database from a custom SQL query.
string | $query | The SQL query. |
array | $binds | Optional. The SQL query parameters. |
Chainable.
setValidator(\Charcoal\Validator\ValidatorInterface $validator) : \Charcoal\Validator\ValidatableInterface
\Charcoal\Validator\ValidatorInterface | $validator | The validator object to use for validation. |
Chainable
validator() : \Charcoal\Validator\ValidatorInterface
validate(\Charcoal\Validator\ValidatorInterface $v = null) : boolean
\Charcoal\Validator\ValidatorInterface | $v | Optional. A custom validator object to use for validation. If null, use object's. |
mergeData(array|\Traversable $data) : \Charcoal\Model\EntityInterface
Override's `\Charcoal\Config\AbstractEntity`'s `setData` method to take properties into consideration.
Also add a special case, to merge values for l10n properties.
array|\Traversable | $data | The data to merge. |
Chainable
setFlatData(array $flatData) : \Charcoal\Model\AbstractModel
Sets the data
This function takes a 1-dimensional array and fill the object with its value.
array | $flatData | The data, as a flat (1-dimension) array. |
Chainable
loadFromL10n(string $key, mixed $value, array $langs) : string
Load an object from the database from its l10n key $key.
Also retrieve and return the actual language that matched.
string | $key | Key pointing a column's l10n base ident. |
mixed | $value | Value to search in all languages. |
array | $langs | List of languages (code, ex: "en") to check into. |
If the PDO query fails.
The matching language.
metadataLoader() : \Charcoal\Model\Service\MetadataLoader
Safe MetdataLoader getter. Create the loader if it does not exist.
If the metadata loader was not set.
createMetadata() : \Charcoal\Model\MetadataInterface
DescribableTrait > createMetadata().
setSourceFactory(\Charcoal\Factory\FactoryInterface $factory) : \Charcoal\Source\StorableInterface
\Charcoal\Factory\FactoryInterface | $factory | The source factory, which is useful to create source. |
Chainable
setIdFromData(array|\Traversable $data) : array|\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.
array|\Traversable | $data | The object data. |
The object data without the pre-set ID.