\Charcoal\ModelDescribableTrait

Default implementation, as trait, of the `DescribableInterface`.

Summary

Methods
Properties
Constants
setData()
setMetadataLoader()
setMetadata()
metadata()
loadMetadata()
setMetadataIdent()
metadataIdent()
No public properties found
No constants found
metadataLoader()
createMetadata()
generateMetadataIdent()
$metadataLoader
$metadata
$metadataIdent
N/A
No private methods found
No private properties found
N/A

Properties

$metadataIdent

$metadataIdent : string

Type

string

Methods

setData()

setData(array  $data) : \Charcoal\Model\DescribableInterface

Describable object needs to have a `setData()` method

Parameters

array $data

The object's data.

Returns

\Charcoal\Model\DescribableInterface

Chainable

setMetadata()

setMetadata(array|\Charcoal\Model\MetadataInterface  $metadata) : \Charcoal\Model\DescribableInterface

Parameters

array|\Charcoal\Model\MetadataInterface $metadata

The object's metadata.

Throws

\InvalidArgumentException

If the parameter is not an array or MetadataInterface.

Returns

\Charcoal\Model\DescribableInterface

Chainable

loadMetadata()

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).

Parameters

string $metadataIdent

Optional ident.

Returns

\Charcoal\Model\MetadataInterface

setMetadataIdent()

setMetadataIdent(string  $metadataIdent) : \Charcoal\Model\DescribableInterface

Parameters

string $metadataIdent

The metadata ident.

Returns

\Charcoal\Model\DescribableInterface

Chainable

metadataIdent()

metadataIdent() : string

Get the metadata ident, or generate it from class name.

Returns

string

metadataLoader()

metadataLoader() : \Charcoal\Model\Service\MetadataLoader

Safe MetdataLoader getter. Create the loader if it does not exist.

Throws

\Exception

If the metadata loader was not set.

Returns

\Charcoal\Model\Service\MetadataLoader

generateMetadataIdent()

generateMetadataIdent() : string

Generate a metadata ident from class name.

Change \ and . to / and force lowercase

Returns

string