Contains logic to convert array data into entities.
Useful when converting request data into entities.
$_table protected Creates a new sub-marshaller and merges the associated data for a BelongstoMany association.
Merges $data into $entity and recursively does the same for each one of the association names passed in $options. When merging associations, if an entity is not present in the parent entity for a given association, a new one will be created.
Merges each of the elements from $data into each of the entities in $entities and recursively does the same for each of the association names passed in $options. When merging associations, if an entity is not present in the parent entity for a given association, a new one will be created.
__construct( Cake\ORM\Table $table )
Constructor.
Cake\ORM\Table $table _belongsToMany( Cake\ORM\Association\BelongsToMany $assoc , array $data , array $options = [] )
Marshals data for belongsToMany associations.
Builds the related entities and handles the special casing for junction table entities.
Cake\ORM\Association\BelongsToMany $assoc $data $options optional [] Cake\Datasource\EntityInterface[]_buildPropertyMap( array $data , array $options )
Build the map of property => marshalling callable.
$data $options _loadAssociatedByIds( Cake\ORM\Association $assoc , array $ids )
Loads a list of belongs to many from ids.
Cake\ORM\Association $assoc $ids Cake\Datasource\EntityInterface[]_loadBelongsToMany( Cake\ORM\Association $assoc , array $ids )
Loads a list of belongs to many from ids.
Cake\ORM\Association $assoc $ids Cake\Datasource\EntityInterface[]_marshalAssociation( Cake\ORM\Association $assoc , array $value , array $options )
Create a new sub-marshaller and marshal the associated data.
Cake\ORM\Association $assoc $value $options Cake\Datasource\EntityInterface|Cake\Datasource\EntityInterface[]|null_mergeAssociation( Cake\Datasource\EntityInterface|Cake\Datasource\EntityInterface[] $original , Cake\ORM\Association $assoc , array $value , array $options )
Creates a new sub-marshaller and merges the associated data.
Cake\Datasource\EntityInterface|Cake\Datasource\EntityInterface[] $original Cake\ORM\Association $assoc $value $options Cake\Datasource\EntityInterface|Cake\Datasource\EntityInterface[]|null_mergeBelongsToMany( Cake\Datasource\EntityInterface $original , Cake\ORM\Association $assoc , array $value , array $options )
Creates a new sub-marshaller and merges the associated data for a BelongstoMany association.
Cake\Datasource\EntityInterface $original Cake\ORM\Association $assoc $value $options Cake\Datasource\EntityInterface[]_mergeJoinData( Cake\Datasource\EntityInterface $original , Cake\ORM\Association\BelongsToMany $assoc , array $value , array $options )
Merge the special _joinData property into the entity set.
Cake\Datasource\EntityInterface $original Cake\ORM\Association\BelongsToMany $assoc $value $options Cake\Datasource\EntityInterface[]_prepareDataAndOptions( array $data , array $options )
Returns data and options prepared to validate and marshall.
$data $options _validate( array $data , array $options , boolean $isNew )
Returns the validation errors for a data set based on the passed options
$data $options $isNew many( array $data , array $options = [] )
Hydrate many entities and their associated data.
$data $options optional [] Cake\Datasource\EntityInterface[]merge( Cake\Datasource\EntityInterface $entity , array $data , array $options = [] )
Merges $data into $entity and recursively does the same for each one of the association names passed in $options. When merging associations, if an entity is not present in the parent entity for a given association, a new one will be created.
When merging HasMany or BelongsToMany associations, all the entities in the $data array will appear, those that can be matched by primary key will get the data merged, but those that cannot, will be discarded. ids option can be used to determine whether the association must use the _ids format.
The above options can be used in each nested associated array. In addition to the above options you can also use the onlyIds option for HasMany and BelongsToMany associations. When true this option restricts the request data to only be read from _ids.
$result = $marshaller->merge($entity, $data, [ 'associated' => ['Tags' => ['onlyIds' => true]] ]);
Cake\Datasource\EntityInterface $entity the entity that will get the data merged in
$data $options optional [] Cake\Datasource\EntityInterfacemergeMany( Cake\Datasource\EntityInterface[]|Traversable $entities , array $data , array $options = [] )
Merges each of the elements from $data into each of the entities in $entities and recursively does the same for each of the association names passed in $options. When merging associations, if an entity is not present in the parent entity for a given association, a new one will be created.
Records in $data are matched against the entities using the primary key column. Entries in $entities that cannot be matched to any record in $data will be discarded. Records in $data that could not be matched will be marshalled as a new entity.
When merging HasMany or BelongsToMany associations, all the entities in the $data array will appear, those that can be matched by primary key will get the data merged, but those that cannot, will be discarded.
Cake\Datasource\EntityInterface[]|Traversable $entities the entities that will get the data merged in
$data $options optional [] Cake\Datasource\EntityInterface[]one( array $data , array $options = [] )
Hydrate one entity and its associated data.
The above options can be used in each nested associated array. In addition to the above options you can also use the onlyIds option for HasMany and BelongsToMany associations. When true this option restricts the request data to only be read from _ids.
$result = $marshaller->one($data, [ 'associated' => ['Tags' => ['onlyIds' => true]] ]);
$data $options optional [] Cake\Datasource\EntityInterface_normalizeAssociations( array $associations )
Returns an array out of the original passed associations list where dot notation is transformed into nested arrays so that they can be parsed by other routines
$associations
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/3.8/class-Cake.ORM.Marshaller.html