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.
__construct( Cake\ORM\Locator\LocatorInterface $tableLocator = null )
Constructor.
Sets the default table locator for associations. If no locator is provided, the global one will be used.
Cake\ORM\Locator\LocatorInterface $tableLocator optional null _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\AssociationcascadeDelete( 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|nullgetByType( 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']
getIterator( )
Allow looping through the associations
IteratorAggregate::getIterator() has( string $alias )
Check for an attached association by name.
$alias keys( )
Get the names of all the associations in the collection.
load( string $className , string $associated , array $options = [] )
Creates and adds the Association object to this collection.
$className $associated $options optional [] Cake\ORM\AssociationnormalizeKeys( 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 getTableLocator( )
Gets the table locator.
Cake\ORM\Locator\LocatorInterfacesetTableLocator( Cake\ORM\Locator\LocatorInterface $tableLocator )
Sets the table locator.
Cake\ORM\Locator\LocatorInterface $tableLocator tableLocator( Cake\ORM\Locator\LocatorInterface $tableLocator = null )
Sets the table locator. If no parameters are passed, it will return the currently used locator.
Cake\ORM\Locator\LocatorInterface $tableLocator optional null Cake\ORM\Locator\LocatorInterface
© 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.AssociationCollection.html