A container/collection for association classes.
Contains methods for managing associations, and ordering operations around saving and deleting.
$_items
protected Cascade a delete across the various associations. Cascade first across associations for which cascadeCallbacks is true.
Returns an associative array of association names out a mixed array. If true is passed, then it returns all association names in this collection.
_getNoCascadeItems( Cake\Datasource\EntityInterface $entity , array $options )
Returns items that have no cascade callback.
Cake\Datasource\EntityInterface
$entity
$options
Cake\ORM\Association[]
_save( Cake\ORM\Association $association , Cake\Datasource\EntityInterface $entity , array $nested , array $options )
Helper method for saving an association's data.
Cake\ORM\Association
$association
Cake\Datasource\EntityInterface
$entity
$nested
$options
_saveAssociations( Cake\ORM\Table $table , Cake\Datasource\EntityInterface $entity , array $associations , array $options , boolean $owningSide )
Helper method for saving an association's data.
Cake\ORM\Table
$table
Cake\Datasource\EntityInterface
$entity
$associations
$options
$owningSide
Compared with association classes' isOwningSide method.
add( string $alias , Cake\ORM\Association $association )
Add an association to the collection
If the alias added contains a .
the part preceding the .
will be dropped. This makes using plugins simpler as the Plugin.Class syntax is frequently used.
$alias
Cake\ORM\Association
$association
Cake\ORM\Association
cascadeDelete( Cake\Datasource\EntityInterface $entity , array $options )
Cascade a delete across the various associations. Cascade first across associations for which cascadeCallbacks is true.
Cake\Datasource\EntityInterface
$entity
$options
get( string $alias )
Fetch an attached association by name.
$alias
Cake\ORM\Association
|nullgetByProperty( string $prop )
Fetch an association by property name.
$prop
Cake\ORM\Association
|nullgetIterator( )
Allow looping through the associations
IteratorAggregate::getIterator()
has( string $alias )
Check for an attached association by name.
$alias
normalizeKeys( boolean|array $keys )
Returns an associative array of association names out a mixed array. If true is passed, then it returns all association names in this collection.
$keys
remove( string $alias )
Drop/remove an association.
Once removed the association will not longer be reachable
$alias
removeAll( )
Remove all registered associations.
Once removed associations will not longer be reachable
saveChildren( Cake\ORM\Table $table , Cake\Datasource\EntityInterface $entity , array $associations , array $options )
Save all the associations that are children of the given entity.
Child associations include any association where the given table is not the owning side.
Cake\ORM\Table
$table
Cake\Datasource\EntityInterface
$entity
$associations
The list of associations to save children from. associations not in this list will not be saved.
$options
saveParents( Cake\ORM\Table $table , Cake\Datasource\EntityInterface $entity , array $associations , array $options [] )
Save all the associations that are parents of the given entity.
Parent associations include any association where the given table is the owning side.
Cake\ORM\Table
$table
Cake\Datasource\EntityInterface
$entity
$associations
The list of associations to save parents from. associations not in this list will not be saved.
$options
optional [] type( string|array $class )
Get an array of associations matching a specific type.
$class
The type of associations you want. For example 'BelongsTo' or array like ['BelongsTo', 'HasOne']
_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–2017 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.4/class-Cake.ORM.AssociationCollection.html