Свойство | Type | Description | |
---|---|---|---|
$_dependent | boolean | Defaults to true for backwards compatibility. | |
$_joinType | string | The type of join to be used when adding the association to a query | |
$_junctionAssociationName | string | The name of the hasMany association from the target table to the junction table | |
$_junctionConditions | null | array | Filtered conditions that reference the junction table. | |
$_junctionProperty | string | The name of the property to be set containing data from the junction table once a record from the target table is hydrated | |
$_junctionTable | Junction table instance | ||
$_junctionTableName | string | Junction table name | |
$_saveStrategy | string | Saving strategy to be used by this association | |
$_strategy | string | The strategy name to be used to fetch associated records. | |
$_targetConditions | null | array | Filtered conditions that reference the target table. | |
$_targetForeignKey | string | array | The name of the field representing the foreign key to the target table | |
$_through | string | |
The table instance for the junction relation. | |
$_validStrategies | array | Valid strategies for this type of association |
Méthode | Description | |
---|---|---|
_buildBaseQuery ( ) | ||
_externalOptions ( ) | ||
attachTo ( |
Alters a Query object to include the associated target table data in the final result | |
cascadeDelete ( Cake\Datasource\EntityInterface $entity, array $options = [] ) : boolean | Clear out the data in the junction table for a given entity. | |
conditions ( $conditions = null ) | {@inheritDoc} | |
find ( string | array | null $type = null, array $options = [] ) : |
Proxies the finding operation to the target table's find method and modifies the query accordingly based of this association configuration. | |
isOwningSide ( |
Returns boolean true, as both of the tables 'own' rows in the other side of the association via the joint table. | |
junction ( string | |
Sets the table instance for the junction relation. If no arguments are passed, the current configured table instance is returned | |
link ( Cake\Datasource\EntityInterface $sourceEntity, array $targetEntities, array $options = [] ) : boolean | Associates the source entity to each of the target entities provided by creating links in the junction table. Both the source entity and each of the target entities are assumed to be already persisted, if they are marked as new or their status is unknown then an exception will be thrown. | |
replaceLinks ( Cake\Datasource\EntityInterface $sourceEntity, array $targetEntities, array $options = [] ) : boolean | Replaces existing association links between the source entity and the target with the ones passed. This method does a smart cleanup, links that are already persisted and present in $targetEntities will not be deleted, new links will be created for the passed target entities that are not already in the database and the rest will be removed. | |
saveAssociated ( Cake\Datasource\EntityInterface $entity, array $options = [] ) : boolean | Cake\Datasource\EntityInterface | Takes an entity from the source table and looks if there is a field matching the property name for this association. The found entity will be saved on the target table for this association by passing supplied $options | |
saveStrategy ( string | null $strategy = null ) : string | Sets the strategy that should be used for saving. If called with no arguments, it will return the currently configured strategy | |
targetForeignKey ( string | null $key = null ) : string | Sets the name of the field representing the foreign key to the target table. | |
type ( ) : string | Get the relationship type. | |
unlink ( Cake\Datasource\EntityInterface $sourceEntity, array $targetEntities, array | boolean $options = [] ) : boolean | Removes all links between the passed source entity and each of the provided target entities. This method assumes that all passed objects are already persisted in the database and that each of them contain a primary key value. |
Méthode | Description | |
---|---|---|
_appendJunctionJoin ( |
Append a join to the junction table. | |
_appendNotMatching ( $query, $options ) | {@inheritDoc} | |
_buildQuery ( array $options ) : |
Auxiliary function to construct a new Query object to return all the records in the target table that are associated to those specified in $options from the source table. | |
_buildResultMap ( |
Builds an array containing the results from fetchQuery indexed by the foreignKey value corresponding to this association. | |
_checkPersistenceStatus ( Cake\Datasource\EntityInterface $sourceEntity, array $targetEntities ) : boolean | Throws an exception should any of the passed entities is not persisted. | |
_collectJointEntities ( Cake\Datasource\EntityInterface $sourceEntity, array $targetEntities ) : array | Returns the list of joint entities that exist between the source entity and each of the passed target entities | |
_diffLinks ( |
Helper method used to delete the difference between the links passed in $existing and $jointEntities. This method will return the values from $targetEntities that were not deleted from calculating the difference. | |
_generateJunctionAssociations ( |
Generate associations on the junction table as necessary | |
_generateSourceAssociations ( |
Generate additional source table associations as necessary. | |
_generateTargetAssociations ( |
Generate reciprocal associations as necessary. | |
_joinCondition ( array $options ) : boolean | Return false as join conditions are defined in the junction table | |
_junctionAssociationName ( ) : string | Returns the name of the association from the target table to the junction table, this name is used to generate alias in the query and to later on retrieve the results. | |
_junctionTableName ( string | null $name = null ) : string | Sets the name of the junction table. | |
_linkField ( array $options ) : string | Generates a string used as a table field that contains the values upon which the filter should be applied | |
_options ( array $opts ) : void | Parse extra options passed in the constructor. | |
_saveLinks ( Cake\Datasource\EntityInterface $sourceEntity, array $targetEntities, array $options ) : boolean | Creates links between the source entity and each of the passed target entities | |
_saveTarget ( Cake\Datasource\EntityInterface $parentEntity, array | Traversable $entities, array $options ) : Cake\Datasource\EntityInterface | boolean | Persists each of the entities into the target table and creates links between the parent entity and each one of the saved target entities. | |
junctionConditions ( ) : array | Returns filtered conditions that specifically reference the junction table. | |
targetConditions ( ) : mixed | Returns filtered conditions that reference the target table. |
protected _appendJunctionJoin ( |
||
$query | The query to append. | |
$conditions | string | array | The query conditions to use. |
Résultat | The modified query. |
protected _appendNotMatching ( $query, $options ) |
protected _buildQuery ( array $options ) : |
||
$options | array | options accepted by eagerLoader() |
Résultat |
protected _buildResultMap ( |
||
$fetchQuery | The query to get results from | |
$options | array | The options passed to the eager loader |
Résultat | array |
protected _checkPersistenceStatus ( Cake\Datasource\EntityInterface $sourceEntity, array $targetEntities ) : boolean | ||
$sourceEntity | Cake\Datasource\EntityInterface | the row belonging to the `source` side of this association |
$targetEntities | array | list of entities belonging to the `target` side of this association |
Résultat | boolean |
protected _collectJointEntities ( Cake\Datasource\EntityInterface $sourceEntity, array $targetEntities ) : array | ||
$sourceEntity | Cake\Datasource\EntityInterface | The row belonging to the source side of this association. |
$targetEntities | array | The rows belonging to the target side of this association. |
Résultat | array |
protected _diffLinks ( |
||
$existing | a query for getting existing links | |
$jointEntities | array | link entities that should be persisted |
$targetEntities | array | entities in target table that are related to the `$jointEntities` |
$options | array | list of options accepted by `Table::delete()` |
Résultat | array |
protected _generateJunctionAssociations ( |
||
$junction | The junction table. | |
$source | The source table. | |
$target | The target table. | |
Résultat | void |
protected _generateSourceAssociations ( |
||
$junction | The junction table. | |
$source | The source table. | |
Résultat | void |
protected _generateTargetAssociations ( |
||
$junction | The junction table. | |
$source | The source table. | |
$target | The target table. | |
Résultat | void |
protected _joinCondition ( array $options ) : boolean | ||
$options | array | list of options passed to attachTo method |
Résultat | boolean | false |
protected _junctionAssociationName ( ) : string | ||
Résultat | string |
protected _linkField ( array $options ) : string | ||
$options | array | the options to use for getting the link field. |
Résultat | string |
protected _saveLinks ( Cake\Datasource\EntityInterface $sourceEntity, array $targetEntities, array $options ) : boolean | ||
$sourceEntity | Cake\Datasource\EntityInterface | the entity from source table in this association |
$targetEntities | array | list of entities to link to link to the source entity using the junction table |
$options | array | list of options accepted by `Table::save()` |
Résultat | boolean | success |
protected _saveTarget ( Cake\Datasource\EntityInterface $parentEntity, array | Traversable $entities, array $options ) : Cake\Datasource\EntityInterface | boolean | ||
$parentEntity | Cake\Datasource\EntityInterface | the source entity containing the target entities to be saved. |
$entities | array | Traversable | list of entities to persist in target table and to link to the parent entity |
$options | array | list of options accepted by `Table::save()` |
Résultat | Cake\Datasource\EntityInterface | boolean | The parent entity after all links have been created if no errors happened, false otherwise |
public cascadeDelete ( Cake\Datasource\EntityInterface $entity, array $options = [] ) : boolean | ||
$entity | Cake\Datasource\EntityInterface | The entity that started the cascading delete. |
$options | array | The options for the original delete. |
Résultat | boolean | Success. |
public isOwningSide ( |
||
$side | The potential Table with ownership | |
Résultat | boolean |
protected junctionConditions ( ) : array | ||
Résultat | array |
public link ( Cake\Datasource\EntityInterface $sourceEntity, array $targetEntities, array $options = [] ) : boolean | ||
$sourceEntity | Cake\Datasource\EntityInterface | the row belonging to the `source` side of this association |
$targetEntities | array | list of entities belonging to the `target` side of this association |
$options | array | list of options to be passed to the internal `save` call |
Résultat | boolean | true on success, false otherwise |
public replaceLinks ( Cake\Datasource\EntityInterface $sourceEntity, array $targetEntities, array $options = [] ) : boolean | ||
$sourceEntity | Cake\Datasource\EntityInterface | an entity persisted in the source table for this association |
$targetEntities | array | list of entities from the target table to be linked |
$options | array | list of options to be passed to the internal `save`/`delete` calls when persisting/updating new links, or deleting existing ones |
Résultat | boolean | success |
public saveAssociated ( Cake\Datasource\EntityInterface $entity, array $options = [] ) : boolean | Cake\Datasource\EntityInterface | ||
$entity | Cake\Datasource\EntityInterface | an entity from the source table |
$options | array | options to be passed to the save method in the target table |
Résultat | boolean | Cake\Datasource\EntityInterface | false if $entity could not be saved, otherwise it returns the saved entity |
protected targetConditions ( ) : mixed | ||
Résultat | mixed | Generally an array. If the conditions are not an array, the association conditions will be returned unmodified. |
public unlink ( Cake\Datasource\EntityInterface $sourceEntity, array $targetEntities, array | boolean $options = [] ) : boolean | ||
$sourceEntity | Cake\Datasource\EntityInterface | an entity persisted in the source table for this association |
$targetEntities | array | list of entities persisted in the target table for this association |
$options | array | boolean | list of options to be passed to the internal `delete` call, or a `boolean` |
Résultat | boolean | Success |
protected bool $_dependent | ||
Résultat | boolean |
protected string $_joinType | ||
Résultat | string |
protected string $_junctionAssociationName | ||
Résultat | string |
protected string $_junctionProperty | ||
Résultat | string |
protected Table,Cake\ORM $_junctionTable | ||
Résultat |
protected string $_junctionTableName | ||
Résultat | string |
protected string $_saveStrategy | ||
Résultat | string |
protected string $_strategy | ||
Résultat | string |
protected string|Table,Cake\ORM $_through | ||
Résultat | string | |
protected array $_validStrategies | ||
Résultat | array |