A container/collection for association classes.
Contains methods for managing associations, and ordering operations around saving and deleting.
arrayCake\ORM\Association>Stored associations
Cake\ORM\Locator\LocatorInterface|nullTable locator instance
string|nullThis object's default table alias.
Constructor.
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
Helper method for saving an association's data.
Helper method for saving an association's data.
Add an association to the collection
Cascade a delete across the various associations. Cascade first across associations for which cascadeCallbacks is true.
Convenience method to get a table instance.
Fetch an attached association by name.
Fetch an association by property name.
Get an array of associations matching a specific type.
Allow looping through the associations
Gets the table locator.
Check for an attached association by name.
Get the names of all the associations in the collection.
Creates and adds the Association object to this collection.
Returns an associative array of association names out a mixed array. If true is passed, then it returns all association names in this collection.
Drop/remove an association.
Remove all registered associations.
Save all the associations that are children of the given entity.
Save all the associations that are parents of the given entity.
Sets the table locator.
__construct(Cake\ORM\Locator\LocatorInterface|null $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|null $tableLocator optional Table locator instance.
_normalizeAssociations(array|string $associations): array
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
array|string $associations The array of included associations.
array_save(Cake\ORM\Association $association, Cake\Datasource\EntityInterface $entity, array<string, mixed> $nested, array<string, mixed> $options): bool
Helper method for saving an association's data.
Cake\ORM\Association $association The association object to save with.
Cake\Datasource\EntityInterface $entity The entity to save
array<string, mixed> $nested Options for deeper associations
array<string, mixed> $options Original options
bool_saveAssociations(Cake\ORM\Table $table, Cake\Datasource\EntityInterface $entity, array $associations, array<string, mixed> $options, bool $owningSide): bool
Helper method for saving an association's data.
Cake\ORM\Table $table The table the save is currently operating on
Cake\Datasource\EntityInterface $entity The entity to save
array $associations Array of associations to save.
array<string, mixed> $options Original options
bool $owningSide Compared with association classes' isOwningSide method.
boolInvalidArgumentExceptionadd(string $alias, Cake\ORM\Association $association): Cake\ORM\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.
string $alias The association alias
Cake\ORM\Association $association The association to add.
Cake\ORM\AssociationcascadeDelete(Cake\Datasource\EntityInterface $entity, array<string, mixed> $options): bool
Cascade a delete across the various associations. Cascade first across associations for which cascadeCallbacks is true.
Cake\Datasource\EntityInterface $entity The entity to delete associations for.
array<string, mixed> $options The options used in the delete operation.
boolfetchTable(string|null $alias = null, array<string, mixed> $options = []): Cake\ORM\Table
Convenience method to get a table instance.
string|null $alias optional The alias name you want to get. Should be in CamelCase format. If null then the value of $defaultTable property is used.
array<string, mixed> $options optional The options you want to build the table with. If a table has already been loaded the registry options will be ignored.
Cake\ORM\TableCake\Core\Exception\CakeExceptionget(string $alias): Cake\ORM\Association|null
Fetch an attached association by name.
string $alias The association alias to get.
Cake\ORM\Association|nullgetByProperty(string $prop): Cake\ORM\Association|null
Fetch an association by property name.
string $prop The property to find an association by.
Cake\ORM\Association|nullgetByType(array<string>|string $class): arrayCake\ORM\Association>
Get an array of associations matching a specific type.
array<string>|string $class The type of associations you want. For example 'BelongsTo' or array like ['BelongsTo', 'HasOne']
arrayCake\ORM\Association>getIterator(): Traversable<string,Cake\ORM\Association>
Allow looping through the associations
Traversable<string,Cake\ORM\Association>getTableLocator(): Cake\ORM\Locator\LocatorInterface
Gets the table locator.
Cake\ORM\Locator\LocatorInterfacehas(string $alias): bool
Check for an attached association by name.
string $alias The association alias to get.
boolkeys(): array<string>
Get the names of all the associations in the collection.
array<string>load(string $className, string $associated, array<string, mixed> $options = []): Cake\ORM\Association
Creates and adds the Association object to this collection.
string $className The name of association class.
string $associated The alias for the target table.
array<string, mixed> $options optional List of options to configure the association definition.
Cake\ORM\AssociationInvalidArgumentExceptionnormalizeKeys(array|bool $keys): array
Returns an associative array of association names out a mixed array. If true is passed, then it returns all association names in this collection.
array|bool $keys the list of association names to normalize
arrayremove(string $alias): void
Drop/remove an association.
Once removed the association will no longer be reachable
string $alias The alias name.
voidremoveAll(): void
Remove all registered associations.
Once removed associations will no longer be reachable
voidsaveChildren(Cake\ORM\Table $table, Cake\Datasource\EntityInterface $entity, array $associations, array<string, mixed> $options): bool
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 The table entity is for.
Cake\Datasource\EntityInterface $entity The entity to save associated data for.
array $associations The list of associations to save children from. associations not in this list will not be saved.
array<string, mixed> $options The options for the save operation.
boolsaveParents(Cake\ORM\Table $table, Cake\Datasource\EntityInterface $entity, array $associations, array<string, mixed> $options = []): bool
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 The table entity is for.
Cake\Datasource\EntityInterface $entity The entity to save associated data for.
array $associations The list of associations to save parents from. associations not in this list will not be saved.
array<string, mixed> $options optional The options for the save operation.
boolsetTableLocator(Cake\ORM\Locator\LocatorInterface $tableLocator): $this
Sets the table locator.
Cake\ORM\Locator\LocatorInterface $tableLocator LocatorInterface instance.
$thisStored associations
arrayCake\ORM\Association>Table locator instance
Cake\ORM\Locator\LocatorInterface|nullThis object's default table alias.
string|null
© 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/4.4/class-Cake.ORM.AssociationCollection.html