PHP Class Mongolid\DataMapper\EntityAssembler

This class is meant to do the opposite of the SchemaMapper.
See also: http://martinfowler.com/eaaCatalog/dataTransferObject.html
Datei anzeigen Open project: leroy-merlin-br/mongolid Class Usage Examples

Public Methods

Method Description
assemble ( array | object $document, Schema $schema ) : mixed Builds an object from the provided data.

Protected Methods

Method Description
assembleDocumentsRecursively ( mixed $value, string $schemaClass ) : mixed Assembly multiple documents for the given $schemaClass recursively.
morphingTime ( mixed $entity ) : mixed Returns the return of polymorph method of the given entity if available.
prepareOriginalAttributes ( mixed $entity ) : mixed Stores original attributes from Entity if needed.

Method Details

assemble() public method

Builds an object from the provided data.
public assemble ( array | object $document, Schema $schema ) : mixed
$document array | object The attributes that will be used to compose the entity.
$schema Mongolid\Schema\Schema Schema that will be used to map each field.
return mixed

assembleDocumentsRecursively() protected method

Assembly multiple documents for the given $schemaClass recursively.
protected assembleDocumentsRecursively ( mixed $value, string $schemaClass ) : mixed
$value mixed A value of an embeded field containing entity data to be assembled.
$schemaClass string The schemaClass to be used when assembling the entities within $value.
return mixed

morphingTime() protected method

Returns the return of polymorph method of the given entity if available.
See also: Mongolid\Model\PolymorphableInterface::polymorph
See also: https://i.ytimg.com/vi/TFGN9kAjdis/maxresdefault.jpg
protected morphingTime ( mixed $entity ) : mixed
$entity mixed The entity that may or may not have a polymorph method.
return mixed The result of $entity->polymorph or the $entity itself.

prepareOriginalAttributes() protected method

Stores original attributes from Entity if needed.
protected prepareOriginalAttributes ( mixed $entity ) : mixed
$entity mixed The entity that may have the attributes stored.
return mixed The entity with original attributes.