PHP Class Mongolid\DataMapper\EntityAssembler

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

Méthodes publiques

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

Méthodes protégées

Méthode 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 méthode

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.
Résultat mixed

assembleDocumentsRecursively() protected méthode

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.
Résultat mixed

morphingTime() protected méthode

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.
Résultat mixed The result of $entity->polymorph or the $entity itself.

prepareOriginalAttributes() protected méthode

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