Fr3nch13/CakePHP Utilities

HasOne extends Association
in package

Represents an 1 - 1 relationship where the source side of the relation is related to only one record in the target table and vice versa.

An example of a HasOne association would be User has one Profile.

Table of Contents

Constants

MANY_TO_MANY  = 'manyToMany'
Association type for many to many associations.
MANY_TO_ONE  = 'manyToOne'
Association type for many to one associations.
ONE_TO_MANY  = 'oneToMany'
Association type for one to many associations.
ONE_TO_ONE  = 'oneToOne'
Association type for one to one associations.
STRATEGY_JOIN  = 'join'
Strategy name to use joins for fetching associated records
STRATEGY_SELECT  = 'select'
Strategy name to use a select for fetching associated records
STRATEGY_SUBQUERY  = 'subquery'
Strategy name to use a subquery for fetching associated records

Properties

$_bindingKey  : array<string|int, string>|string|null
The field name in the owning side table that is used to match with the foreignKey
$_cascadeCallbacks  : bool
Whether cascaded deletes should also fire callbacks.
$_className  : string
The class name of the target table object
$_conditions  : Closure|array<string|int, mixed>
A list of conditions to be always included when fetching records from the target association
$_dependent  : bool
Whether the records on the target table are dependent on the source table, often used to indicate that records should be removed if the owning record in the source table is deleted.
$_finder  : array<string|int, mixed>|string
The default finder name to use for fetching rows from the target table With array value, finder name and default options are allowed.
$_foreignKey  : array<string|int, string>|string
The name of the field representing the foreign key to the table to load
$_joinType  : string
The type of join to be used when adding the association to a query
$_name  : string
Name given to the association, it usually represents the alias assigned to the target associated table
$_propertyName  : string
The property name that should be filled with data from the target table in the source table record.
$_sourceTable  : Table
Source table instance
$_strategy  : string
The strategy name to be used to fetch associated records. Some association types might not implement but one strategy to fetch records.
$_tableLocator  : LocatorInterface|null
Table locator instance
$_targetTable  : Table
Target table instance
$_validStrategies  : array<string|int, string>
Valid strategies for this type of association
$defaultTable  : string|null
This object's default table alias.

Methods

__call()  : mixed
Proxies method calls to the target table.
__construct()  : mixed
Constructor. Subclasses can override _options function to get the original list of passed options if expecting any other special key
__get()  : Association
Proxies property retrieval to the target table. This is handy for getting this association's associations
__isset()  : bool
Proxies the isset call to the target table. This is handy to check if the target table has another association with the passed name
attachTo()  : void
Alters a Query object to include the associated target table data in the final result
canBeJoined()  : bool
Whether this association can be expressed directly in a query join
cascadeDelete()  : bool
Handles cascading a delete from an associated model.
defaultRowValue()  : array<string, mixed>
Returns a modified row after appending a property for this association with the default empty value according to whether the association was joined or fetched externally.
deleteAll()  : int
Proxies the delete operation to the target table's deleteAll method
eagerLoader()  : Closure
Eager loads a list of records in the target table that are related to another set of records in the source table. Source records can be specified in two ways: first one is by passing a Query object setup to find on the source table and the other way is by explicitly passing an array of primary key values from the source table.
exists()  : bool
Proxies the operation to the target table's exists method after appending the default conditions for this association
fetchTable()  : Table
Convenience method to get a table instance.
find()  : Query
Proxies the finding operation to the target table's find method and modifies the query accordingly based of this association configuration
getBindingKey()  : array<string|int, string>|string
Gets the name of the field representing the binding field with the target table.
getCascadeCallbacks()  : bool
Gets whether cascaded deletes should also fire callbacks.
getClassName()  : string
Gets the class name of the target table object.
getConditions()  : Closure|array<string|int, mixed>
Gets a list of conditions to be always included when fetching records from the target association.
getDependent()  : bool
Sets whether the records on the target table are dependent on the source table.
getFinder()  : array<string|int, mixed>|string
Gets the default finder to use for fetching rows from the target table.
getForeignKey()  : array<string|int, string>|string
Gets the name of the field representing the foreign key to the target table.
getJoinType()  : string
Gets the type of join to be used when adding the association to a query.
getName()  : string
Gets the name for this association, usually the alias assigned to the target associated table
getProperty()  : string
Gets the property name that should be filled with data from the target table in the source table record.
getSource()  : Table
Gets the table instance for the source side of the association.
getStrategy()  : string
Gets the strategy name to be used to fetch associated records. Keep in mind that some association types might not implement but a default strategy, rendering any changes to this setting void.
getTableLocator()  : LocatorInterface
Gets the table locator.
getTarget()  : Table
Gets the table instance for the target side of the association.
isOwningSide()  : bool
Returns whether the passed table is the owning side for this association. This means that rows in the 'target' table would miss important or required information if the row in 'source' did not exist.
requiresKeys()  : bool
Returns true if the eager loading process will require a set of the owning table's binding keys in order to use them as a filter in the finder query.
saveAssociated()  : EntityInterface|false
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`
setBindingKey()  : $this
Sets the name of the field representing the binding field with the target table.
setCascadeCallbacks()  : $this
Sets whether cascaded deletes should also fire callbacks.
setClassName()  : $this
Sets the class name of the target table object.
setConditions()  : $this
Sets a list of conditions to be always included when fetching records from the target association.
setDependent()  : $this
Sets whether the records on the target table are dependent on the source table.
setFinder()  : $this
Sets the default finder to use for fetching rows from the target table.
setForeignKey()  : $this
Sets the name of the field representing the foreign key to the target table.
setJoinType()  : $this
Sets the type of join to be used when adding the association to a query.
setName()  : $this
Sets the name for this association, usually the alias assigned to the target associated table
setProperty()  : $this
Sets the property name that should be filled with data from the target table in the source table record.
setSource()  : $this
Sets the table instance for the source side of the association.
setStrategy()  : $this
Sets the strategy name to be used to fetch associated records. Keep in mind that some association types might not implement but a default strategy, rendering any changes to this setting void.
setTableLocator()  : $this
Sets the table locator.
setTarget()  : $this
Sets the table instance for the target side of the association.
transformRow()  : array<string|int, mixed>
Correctly nests a result row associated values into the correct array keys inside the source results.
type()  : string
Get the relationship type.
updateAll()  : int
Proxies the update operation to the target table's updateAll method
_appendFields()  : void
Helper function used to conditionally append fields to the select clause of a query from the fields found in another query object.
_appendNotMatching()  : void
Conditionally adds a condition to the passed Query that will make it find records where there is no match with this association.
_bindNewAssociations()  : void
Applies all attachable associations to `$query` out of the containments found in the `$surrogate` query.
_camelize()  : string
Creates a camelized version of $name
_dispatchBeforeFind()  : void
Triggers beforeFind on the target table for the query this association is attaching to
_entityName()  : string
Creates the proper entity name (singular) for the specified name
_extractFinder()  : array<string|int, mixed>
Helper method to infer the requested finder and its options.
_fixtureName()  : string
Creates a fixture name
_formatAssociationResults()  : void
Adds a formatter function to the passed `$query` if the `$surrogate` query declares any other formatter. Since the `$surrogate` query correspond to the associated target table, the resulting formatter will be the result of applying the surrogate formatters to only the property corresponding to such table.
_joinCondition()  : array<string|int, mixed>
Returns a single or multiple conditions to be appended to the generated join clause for getting the results on the target table.
_modelKey()  : string
Creates the proper underscored model key for associations
_modelNameFromKey()  : string
Creates the proper model name from a foreign key
_options()  : void
Override this function to initialize any concrete association class, it will get passed the original list of options used in the constructor
_pluginNamespace()  : string
Return plugin's namespace
_pluginPath()  : string
Find the correct path for a plugin. Scans $pluginPaths for the plugin you want.
_pluralHumanName()  : string
Creates the plural human name used in views
_propertyName()  : string
Returns default property name based on association name.
_singularHumanName()  : string
Creates the singular human name used in views
_singularName()  : string
Creates the singular name for use in views.
_variableName()  : string
Creates the plural variable name for views

Constants

MANY_TO_MANY

Association type for many to many associations.

public string MANY_TO_MANY = 'manyToMany'

MANY_TO_ONE

Association type for many to one associations.

public string MANY_TO_ONE = 'manyToOne'

ONE_TO_MANY

Association type for one to many associations.

public string ONE_TO_MANY = 'oneToMany'

ONE_TO_ONE

Association type for one to one associations.

public string ONE_TO_ONE = 'oneToOne'

STRATEGY_JOIN

Strategy name to use joins for fetching associated records

public string STRATEGY_JOIN = 'join'

STRATEGY_SELECT

Strategy name to use a select for fetching associated records

public string STRATEGY_SELECT = 'select'

STRATEGY_SUBQUERY

Strategy name to use a subquery for fetching associated records

public string STRATEGY_SUBQUERY = 'subquery'

Properties

$_bindingKey

The field name in the owning side table that is used to match with the foreignKey

protected array<string|int, string>|string|null $_bindingKey

$_cascadeCallbacks

Whether cascaded deletes should also fire callbacks.

protected bool $_cascadeCallbacks = false

$_className

The class name of the target table object

protected string $_className

$_conditions

A list of conditions to be always included when fetching records from the target association

protected Closure|array<string|int, mixed> $_conditions = []

$_dependent

Whether the records on the target table are dependent on the source table, often used to indicate that records should be removed if the owning record in the source table is deleted.

protected bool $_dependent = false

$_finder

The default finder name to use for fetching rows from the target table With array value, finder name and default options are allowed.

protected array<string|int, mixed>|string $_finder = 'all'

$_foreignKey

The name of the field representing the foreign key to the table to load

protected array<string|int, string>|string $_foreignKey

$_joinType

The type of join to be used when adding the association to a query

protected string $_joinType = \Cake\ORM\Query::JOIN_TYPE_LEFT

$_name

Name given to the association, it usually represents the alias assigned to the target associated table

protected string $_name

$_propertyName

The property name that should be filled with data from the target table in the source table record.

protected string $_propertyName

$_strategy

The strategy name to be used to fetch associated records. Some association types might not implement but one strategy to fetch records.

protected string $_strategy = self::STRATEGY_JOIN

$_validStrategies

Valid strategies for this type of association

protected array<string|int, string> $_validStrategies = [self::STRATEGY_JOIN, self::STRATEGY_SELECT]

$defaultTable

This object's default table alias.

protected string|null $defaultTable = null

Methods

__call()

Proxies method calls to the target table.

public __call(string $method, array<string|int, mixed> $argument) : mixed
Parameters
$method : string

name of the method to be invoked

$argument : array<string|int, mixed>

List of arguments passed to the function

Tags
throws
BadMethodCallException

__construct()

Constructor. Subclasses can override _options function to get the original list of passed options if expecting any other special key

public __construct(string $alias[, array<string, mixed> $options = [] ]) : mixed
Parameters
$alias : string

The name given to the association

$options : array<string, mixed> = []

A list of properties to be set on this object

__get()

Proxies property retrieval to the target table. This is handy for getting this association's associations

public __get(string $property) : Association
Parameters
$property : string

the property name

Tags
throws
RuntimeException

if no association with such name exists

Return values
Association

__isset()

Proxies the isset call to the target table. This is handy to check if the target table has another association with the passed name

public __isset(string $property) : bool
Parameters
$property : string

the property name

Return values
bool

true if the property exists

attachTo()

Alters a Query object to include the associated target table data in the final result

public attachTo(Query $query[, array<string, mixed> $options = [] ]) : void

The options array accept the following keys:

  • includeFields: Whether to include target model fields in the result or not
  • foreignKey: The name of the field to use as foreign key, if false none will be used
  • conditions: array with a list of conditions to filter the join with, this will be merged with any conditions originally configured for this association
  • fields: a list of fields in the target table to include in the result
  • aliasPath: A dot separated string representing the path of association names followed from the passed query main table to this association.
  • propertyPath: A dot separated string representing the path of association properties to be followed from the passed query main entity to this association
  • joinType: The SQL join type to use in the query.
  • negateMatch: Will append a condition to the passed query for excluding matches. with this association.
Parameters
$query : Query

the query to be altered to include the target table data

$options : array<string, mixed> = []

Any extra options or overrides to be taken in account

Tags
throws
RuntimeException

Unable to build the query or associations.

canBeJoined()

Whether this association can be expressed directly in a query join

public canBeJoined([array<string, mixed> $options = [] ]) : bool
Parameters
$options : array<string, mixed> = []

custom options key that could alter the return value

Return values
bool

cascadeDelete()

Handles cascading a delete from an associated model.

public cascadeDelete(EntityInterface $entity[, array<string|int, mixed> $options = [] ]) : bool
Parameters
$entity : EntityInterface

The entity that started the cascaded delete.

$options : array<string|int, mixed> = []

The options for the original delete.

Tags
inheritDoc
Return values
bool

Success

defaultRowValue()

Returns a modified row after appending a property for this association with the default empty value according to whether the association was joined or fetched externally.

public defaultRowValue(array<string, mixed> $row, bool $joined) : array<string, mixed>
Parameters
$row : array<string, mixed>

The row to set a default on.

$joined : bool

Whether the row is a result of a direct join with this association

Return values
array<string, mixed>

deleteAll()

Proxies the delete operation to the target table's deleteAll method

public deleteAll(ExpressionInterface|Closure|array<string|int, mixed>|string|null $conditions) : int
Parameters
$conditions : ExpressionInterface|Closure|array<string|int, mixed>|string|null

Conditions to be used, accepts anything Query::where() can take.

Tags
see
Table::deleteAll()
Return values
int

Returns the number of affected rows.

eagerLoader()

Eager loads a list of records in the target table that are related to another set of records in the source table. Source records can be specified in two ways: first one is by passing a Query object setup to find on the source table and the other way is by explicitly passing an array of primary key values from the source table.

public eagerLoader(array<string|int, mixed> $options) : Closure
Parameters
$options : array<string|int, mixed>

The options for eager loading.

Tags
inheritDoc
Return values
Closure

exists()

Proxies the operation to the target table's exists method after appending the default conditions for this association

public exists(ExpressionInterface|Closure|array<string|int, mixed>|string|null $conditions) : bool
Parameters
$conditions : ExpressionInterface|Closure|array<string|int, mixed>|string|null

The conditions to use for checking if any record matches.

Tags
see
Table::exists()
Return values
bool

fetchTable()

Convenience method to get a table instance.

public fetchTable([string|null $alias = null ][, array<string, mixed> $options = [] ]) : Table
Parameters
$alias : string|null = null

The alias name you want to get. Should be in CamelCase format. If null then the value of $defaultTable property is used.

$options : array<string, mixed> = []

The options you want to build the table with. If a table has already been loaded the registry options will be ignored.

Tags
throws
CakeException

If $alias argument and $defaultTable property both are null.

see
TableLocator::get()
since
4.3.0
Return values
Table

find()

Proxies the finding operation to the target table's find method and modifies the query accordingly based of this association configuration

public find([array<string, mixed>|string|null $type = null ][, array<string, mixed> $options = [] ]) : Query
Parameters
$type : array<string, mixed>|string|null = null

the type of query to perform, if an array is passed, it will be interpreted as the $options parameter

$options : array<string, mixed> = []

The options to for the find

Tags
see
Table::find()
Return values
Query

getBindingKey()

Gets the name of the field representing the binding field with the target table.

public getBindingKey() : array<string|int, string>|string

When not manually specified the primary key of the owning side table is used.

Return values
array<string|int, string>|string

getCascadeCallbacks()

Gets whether cascaded deletes should also fire callbacks.

public getCascadeCallbacks() : bool
Return values
bool

getClassName()

Gets the class name of the target table object.

public getClassName() : string
Return values
string

getConditions()

Gets a list of conditions to be always included when fetching records from the target association.

public getConditions() : Closure|array<string|int, mixed>
Tags
see
Query::where()

for examples on the format of the array

Return values
Closure|array<string|int, mixed>

getDependent()

Sets whether the records on the target table are dependent on the source table.

public getDependent() : bool

This is primarily used to indicate that records should be removed if the owning record in the source table is deleted.

Return values
bool

getFinder()

Gets the default finder to use for fetching rows from the target table.

public getFinder() : array<string|int, mixed>|string
Return values
array<string|int, mixed>|string

getForeignKey()

Gets the name of the field representing the foreign key to the target table.

public getForeignKey() : array<string|int, string>|string
Return values
array<string|int, string>|string

getJoinType()

Gets the type of join to be used when adding the association to a query.

public getJoinType() : string
Return values
string

getName()

Gets the name for this association, usually the alias assigned to the target associated table

public getName() : string
Return values
string

getProperty()

Gets the property name that should be filled with data from the target table in the source table record.

public getProperty() : string
Return values
string

getSource()

Gets the table instance for the source side of the association.

public getSource() : Table
Return values
Table

getStrategy()

Gets the strategy name to be used to fetch associated records. Keep in mind that some association types might not implement but a default strategy, rendering any changes to this setting void.

public getStrategy() : string
Return values
string

getTarget()

Gets the table instance for the target side of the association.

public getTarget() : Table
Return values
Table

isOwningSide()

Returns whether the passed table is the owning side for this association. This means that rows in the 'target' table would miss important or required information if the row in 'source' did not exist.

public isOwningSide(Table $side) : bool
Parameters
$side : Table

The potential Table with ownership

Return values
bool

requiresKeys()

Returns true if the eager loading process will require a set of the owning table's binding keys in order to use them as a filter in the finder query.

public requiresKeys([array<string, mixed> $options = [] ]) : bool
Parameters
$options : array<string, mixed> = []

The options containing the strategy to be used.

Return values
bool

true if a list of keys will be required

saveAssociated()

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`

public saveAssociated(EntityInterface $entity[, array<string, mixed> $options = [] ]) : EntityInterface|false
Parameters
$entity : EntityInterface

an entity from the source table

$options : array<string, mixed> = []

options to be passed to the save method in the target table

Tags
see
Table::save()
Return values
EntityInterface|false

false if $entity could not be saved, otherwise it returns the saved entity

setBindingKey()

Sets the name of the field representing the binding field with the target table.

public setBindingKey(array<string|int, string>|string $key) : $this

When not manually specified the primary key of the owning side table is used.

Parameters
$key : array<string|int, string>|string

the table field or fields to be used to link both tables together

Return values
$this

setCascadeCallbacks()

Sets whether cascaded deletes should also fire callbacks.

public setCascadeCallbacks(bool $cascadeCallbacks) : $this
Parameters
$cascadeCallbacks : bool

cascade callbacks switch value

Return values
$this

setClassName()

Sets the class name of the target table object.

public setClassName(string $className) : $this
Parameters
$className : string

Class name to set.

Tags
throws
InvalidArgumentException

In case the class name is set after the target table has been resolved, and it doesn't match the target table's class name.

Return values
$this

setConditions()

Sets a list of conditions to be always included when fetching records from the target association.

public setConditions(Closure|array<string|int, mixed> $conditions) : $this
Parameters
$conditions : Closure|array<string|int, mixed>

list of conditions to be used

Tags
see
Query::where()

for examples on the format of the array

Return values
$this

setDependent()

Sets whether the records on the target table are dependent on the source table.

public setDependent(bool $dependent) : $this

This is primarily used to indicate that records should be removed if the owning record in the source table is deleted.

If no parameters are passed the current setting is returned.

Parameters
$dependent : bool

Set the dependent mode. Use null to read the current state.

Return values
$this

setFinder()

Sets the default finder to use for fetching rows from the target table.

public setFinder(array<string|int, mixed>|string $finder) : $this
Parameters
$finder : array<string|int, mixed>|string

the finder name to use or array of finder name and option.

Return values
$this

setForeignKey()

Sets the name of the field representing the foreign key to the target table.

public setForeignKey(array<string|int, string>|string $key) : $this
Parameters
$key : array<string|int, string>|string

the key or keys to be used to link both tables together

Return values
$this

setJoinType()

Sets the type of join to be used when adding the association to a query.

public setJoinType(string $type) : $this
Parameters
$type : string

the join type to be used (e.g. INNER)

Return values
$this

setName()

Sets the name for this association, usually the alias assigned to the target associated table

public setName(string $name) : $this

Changing the association name after object creation is no longer supported. The name should only be set through the constructor.

Parameters
$name : string

Name to be assigned

Return values
$this

setProperty()

Sets the property name that should be filled with data from the target table in the source table record.

public setProperty(string $name) : $this
Parameters
$name : string

The name of the association property. Use null to read the current value.

Return values
$this

setSource()

Sets the table instance for the source side of the association.

public setSource(Table $table) : $this
Parameters
$table : Table

the instance to be assigned as source side

Return values
$this

setStrategy()

Sets the strategy name to be used to fetch associated records. Keep in mind that some association types might not implement but a default strategy, rendering any changes to this setting void.

public setStrategy(string $name) : $this
Parameters
$name : string

The strategy type. Use null to read the current value.

Tags
throws
InvalidArgumentException

When an invalid strategy is provided.

Return values
$this

setTarget()

Sets the table instance for the target side of the association.

public setTarget(Table $table) : $this
Parameters
$table : Table

the instance to be assigned as target side

Return values
$this

transformRow()

Correctly nests a result row associated values into the correct array keys inside the source results.

public transformRow(array<string|int, mixed> $row, string $nestKey, bool $joined[, string|null $targetProperty = null ]) : array<string|int, mixed>
Parameters
$row : array<string|int, mixed>

The row to transform

$nestKey : string

The array key under which the results for this association should be found

$joined : bool

Whether the row is a result of a direct join with this association

$targetProperty : string|null = null

The property name in the source results where the association data shuld be nested in. Will use the default one if not provided.

Return values
array<string|int, mixed>

type()

Get the relationship type.

public type() : string
Return values
string

updateAll()

Proxies the update operation to the target table's updateAll method

public updateAll(array<string|int, mixed> $fields, ExpressionInterface|Closure|array<string|int, mixed>|string|null $conditions) : int
Parameters
$fields : array<string|int, mixed>

A hash of field => new value.

$conditions : ExpressionInterface|Closure|array<string|int, mixed>|string|null

Conditions to be used, accepts anything Query::where() can take.

Tags
see
Table::updateAll()
Return values
int

Count Returns the affected rows.

_appendFields()

Helper function used to conditionally append fields to the select clause of a query from the fields found in another query object.

protected _appendFields(Query $query, Query $surrogate, array<string, mixed> $options) : void
Parameters
$query : Query

the query that will get the fields appended to

$surrogate : Query

the query having the fields to be copied from

$options : array<string, mixed>

options passed to the method attachTo

_appendNotMatching()

Conditionally adds a condition to the passed Query that will make it find records where there is no match with this association.

protected _appendNotMatching(Query $query, array<string, mixed> $options) : void
Parameters
$query : Query

The query to modify

$options : array<string, mixed>

Options array containing the negateMatch key.

_bindNewAssociations()

Applies all attachable associations to `$query` out of the containments found in the `$surrogate` query.

protected _bindNewAssociations(Query $query, Query $surrogate, array<string, mixed> $options) : void

Copies all contained associations from the $surrogate query into the passed $query. Containments are altered so that they respect the associations chain from which they originated.

Parameters
$query : Query

the query that will get the associations attached to

$surrogate : Query

the query having the containments to be attached

$options : array<string, mixed>

options passed to the method attachTo

_camelize()

Creates a camelized version of $name

protected _camelize(string $name) : string
Parameters
$name : string

name

Return values
string

Camelized name

_dispatchBeforeFind()

Triggers beforeFind on the target table for the query this association is attaching to

protected _dispatchBeforeFind(Query $query) : void
Parameters
$query : Query

the query this association is attaching itself to

_entityName()

Creates the proper entity name (singular) for the specified name

protected _entityName(string $name) : string
Parameters
$name : string

Name

Return values
string

Camelized and plural model name

_extractFinder()

Helper method to infer the requested finder and its options.

protected _extractFinder(array<string|int, mixed>|string $finderData) : array<string|int, mixed>

Returns the inferred options from the finder $type.

Examples:

The following will call the finder 'translations' with the value of the finder as its options: $query->contain(['Comments' => ['finder' => ['translations']]]); $query->contain(['Comments' => ['finder' => ['translations' => []]]]); $query->contain(['Comments' => ['finder' => ['translations' => ['locales' => ['en_US']]]]]);

Parameters
$finderData : array<string|int, mixed>|string

The finder name or an array having the name as key and options as value.

Return values
array<string|int, mixed>

_fixtureName()

Creates a fixture name

protected _fixtureName(string $name) : string
Parameters
$name : string

Model class name

Return values
string

Singular model key

_formatAssociationResults()

Adds a formatter function to the passed `$query` if the `$surrogate` query declares any other formatter. Since the `$surrogate` query correspond to the associated target table, the resulting formatter will be the result of applying the surrogate formatters to only the property corresponding to such table.

protected _formatAssociationResults(Query $query, Query $surrogate, array<string, mixed> $options) : void
Parameters
$query : Query

the query that will get the formatter applied to

$surrogate : Query

the query having formatters for the associated target table.

$options : array<string, mixed>

options passed to the method attachTo

_joinCondition()

Returns a single or multiple conditions to be appended to the generated join clause for getting the results on the target table.

protected _joinCondition(array<string, mixed> $options) : array<string|int, mixed>
Parameters
$options : array<string, mixed>

list of options passed to attachTo method

Tags
throws
RuntimeException

if the number of columns in the foreignKey do not match the number of columns in the source table primaryKey

Return values
array<string|int, mixed>

_modelKey()

Creates the proper underscored model key for associations

protected _modelKey(string $name) : string

If the input contains a dot, assume that the right side is the real table name.

Parameters
$name : string

Model class name

Return values
string

Singular model key

_modelNameFromKey()

Creates the proper model name from a foreign key

protected _modelNameFromKey(string $key) : string
Parameters
$key : string

Foreign key

Return values
string

Model name

_options()

Override this function to initialize any concrete association class, it will get passed the original list of options used in the constructor

protected _options(array<string, mixed> $options) : void
Parameters
$options : array<string, mixed>

List of options used for initialization

_pluginNamespace()

Return plugin's namespace

protected _pluginNamespace(string $pluginName) : string
Parameters
$pluginName : string

Plugin name

Return values
string

Plugin's namespace

_pluginPath()

Find the correct path for a plugin. Scans $pluginPaths for the plugin you want.

protected _pluginPath(string $pluginName) : string
Parameters
$pluginName : string

Name of the plugin you want ie. DebugKit

Return values
string

path path to the correct plugin.

_pluralHumanName()

Creates the plural human name used in views

protected _pluralHumanName(string $name) : string
Parameters
$name : string

Controller name

Return values
string

Plural human name

_propertyName()

Returns default property name based on association name.

protected _propertyName() : string
Return values
string

_singularHumanName()

Creates the singular human name used in views

protected _singularHumanName(string $name) : string
Parameters
$name : string

Controller name

Return values
string

Singular human name

_singularName()

Creates the singular name for use in views.

protected _singularName(string $name) : string
Parameters
$name : string

Name to use

Return values
string

Variable name

_variableName()

Creates the plural variable name for views

protected _variableName(string $name) : string
Parameters
$name : string

Name to use

Return values
string

Plural name for views


        
On this page

Search results