\Charcoal\Model\ServiceModelBuilder

Summary

Methods
Properties
Constants
__construct()
build()
__invoke()
No public properties found
DEFAULT_SOURCE_TYPE
No protected methods found
No protected properties found
N/A
setFactory()
setMetadataLoader()
setSourceFactory()
createMetadata()
createSource()
$factory
$metadataLoader
$sourceFactory
N/A

Constants

DEFAULT_SOURCE_TYPE

DEFAULT_SOURCE_TYPE

Properties

$factory

$factory : \Charcoal\Factory\FactoryInterface

Type

\Charcoal\Factory\FactoryInterface

$sourceFactory

$sourceFactory : \Charcoal\Factory\FactoryInterface

Type

\Charcoal\Factory\FactoryInterface

Methods

__construct()

__construct(array  $data) 

Parameters

array $data

Constructor dependencies.

build()

build(string  $objType, string|null  $metadataIdent = null, string|null  $sourceIdent = null) : \Charcoal\Model\Service\ModelInterface

Build a model, pre-initializing its metadata and its source.

By default, the name of the "obj type" (the model class name) is used to determine the metadata ident to load. To load a custom metadata for the object, use the $metadataIdent argument.

By default, the object's default source (from its metadata) is used as source. To load a custom source for the object, use the $sourceIdent argument.

Parameters

string $objType

The object type of the Model.

string|null $metadataIdent

Optional. The metadata ident of the object.

string|null $sourceIdent

Optional. The custom source ident to load as source.

Returns

\Charcoal\Model\Service\ModelInterface

__invoke()

__invoke(string  $objType, string|null  $metadataIdent = null, string|null  $sourceIdent = null) : \Charcoal\Model\Service\ModelInterface

The builder can be invoked (used as function).

Parameters

string $objType

The object type of the Model.

string|null $metadataIdent

Optional. The metadata ident of the object.

string|null $sourceIdent

Optional. The custom source ident to load as source.

Returns

\Charcoal\Model\Service\ModelInterface

setFactory()

setFactory(\Charcoal\Factory\FactoryInterface  $factory) : \Charcoal\Model\Service\ModelLoaderBuilder

Parameters

\Charcoal\Factory\FactoryInterface $factory

The factory to use to create models.

Returns

\Charcoal\Model\Service\ModelLoaderBuilder

Chainable

setMetadataLoader()

setMetadataLoader(\Charcoal\Model\Service\MetadataLoader  $loader) : \Charcoal\Model\Service\DescribableInterface

Parameters

\Charcoal\Model\Service\MetadataLoader $loader

The loader instance, used to load metadata.

Returns

\Charcoal\Model\Service\DescribableInterface —

Chainable

setSourceFactory()

setSourceFactory(\Charcoal\Factory\FactoryInterface  $factory) : \Charcoal\Model\Service\ModelLoaderBuilder

Parameters

\Charcoal\Factory\FactoryInterface $factory

The factory to use to create models.

Returns

\Charcoal\Model\Service\ModelLoaderBuilder

Chainable

createMetadata()

createMetadata(string  $objType, string|null  $metadataIdent = null) : \Charcoal\Model\Service\MetadataInterface

Parameters

string $objType

The type of object to load. (A class name or object identifier).

string|null $metadataIdent

Optional. The metadata identifier to load. If NULL, it will be implied from objType.

Returns

\Charcoal\Model\Service\MetadataInterface

createSource()

createSource(\Charcoal\Model\ModelMetadata  $metadata, string|null  $sourceIdent = null) : \Charcoal\Model\Service\SourceInterface

Parameters

\Charcoal\Model\ModelMetadata $metadata

The object metadata, where to find the object's source configuration.

string|null $sourceIdent

Optional. Custom source ident to load. If NULL, the default (from metadata) will be used.

Throws

\Exception

If the source is not defined in the model's metadata.

Returns

\Charcoal\Model\Service\SourceInterface