$_tableLocator
$_tableLocator : \Cake\ORM\Locator\LocatorInterface
Table locator instance
A container/collection for association classes.
Contains methods for managing associations, and ordering operations around saving and deleting.
$_tableLocator : \Cake\ORM\Locator\LocatorInterface
Table locator instance
$_items : array<mixed,\Cake\ORM\Association>
Stored associations
tableLocator(\Cake\ORM\Locator\LocatorInterface|null $tableLocator = null) : \Cake\ORM\Locator\LocatorInterface
Sets the table locator.
If no parameters are passed, it will return the currently used locator.
\Cake\ORM\Locator\LocatorInterface|null | $tableLocator | LocatorInterface instance. |
setTableLocator(\Cake\ORM\Locator\LocatorInterface $tableLocator) : $this
Sets the table locator.
\Cake\ORM\Locator\LocatorInterface | $tableLocator | LocatorInterface instance. |
None found |
getTableLocator() : \Cake\ORM\Locator\LocatorInterface
Gets the table locator.
None found |
__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 | Table locator instance. |
None found |
add(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. |
The association object being added.
None found |
load(string $className, string $associated, array $options = array()) : \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 | $options | List of options to configure the association definition. |
None found |
get(string $alias) : \Cake\ORM\Association|null
Fetch an attached association by name.
string | $alias | The association alias to get. |
Either the association or null.
None found |
getByProperty(string $prop) : \Cake\ORM\Association|null
Fetch an association by property name.
string | $prop | The property to find an association by. |
Either the association or null.
None found |
has(string $alias) : boolean
Check for an attached association by name.
string | $alias | The association alias to get. |
Whether or not the association exists.
None found |
keys() : array<mixed,string>
Get the names of all the associations in the collection.
None found |
type(string|array $class) : array
Get an array of associations matching a specific type.
string|array | $class | The type of associations you want. For example 'BelongsTo' or array like ['BelongsTo', 'HasOne'] |
An array of Association objects.
None found |
getByType(string|array $class) : array
Get an array of associations matching a specific type.
string|array | $class | The type of associations you want. For example 'BelongsTo' or array like ['BelongsTo', 'HasOne'] |
An array of Association objects.
since | 3.5.3 |
---|
remove(string $alias) : void
Drop/remove an association.
Once removed the association will not longer be reachable
string | $alias | The alias name. |
None found |
removeAll() : void
Remove all registered associations.
Once removed associations will not longer be reachable
None found |
saveParents(\Cake\ORM\Table $table, \Cake\Datasource\EntityInterface $entity, array $associations, array $options = array()) : boolean
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 | $options | The options for the save operation. |
Success
None found |
saveChildren(\Cake\ORM\Table $table, \Cake\Datasource\EntityInterface $entity, array $associations, array $options) : boolean
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 | $options | The options for the save operation. |
Success
None found |
cascadeDelete(\Cake\Datasource\EntityInterface $entity, array $options) : void
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 | $options | The options used in the delete operation. |
None found |
normalizeKeys(boolean|array $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.
boolean|array | $keys | the list of association names to normalize |
None found |
getIterator() : \ArrayIterator
Allow looping through the associations
None found |
_normalizeAssociations(array $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 | $associations | The array of included associations. |
An array having dot notation transformed into nested arrays
None found |
_saveAssociations(\Cake\ORM\Table $table, \Cake\Datasource\EntityInterface $entity, array $associations, array $options, boolean $owningSide) : boolean
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 | $options | Original options |
boolean | $owningSide | Compared with association classes' isOwningSide method. |
When an unknown alias is used.
Success
None found |
_save(\Cake\ORM\Association $association, \Cake\Datasource\EntityInterface $entity, array $nested, array $options) : boolean
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 | $nested | Options for deeper associations |
array | $options | Original options |
Success
None found |
_getNoCascadeItems(\Cake\Datasource\EntityInterface $entity, array $options) : array<mixed,\Cake\ORM\Association>
Returns items that have no cascade callback.
\Cake\Datasource\EntityInterface | $entity | The entity to delete associations for. |
array | $options | The options used in the delete operation. |
None found |