On this page
Class LinkConstraint
Checks whether links to a given association exist / do not exist.
Constants
-
stringSTATUS_LINKED'linked'Status that requires a link to be present.
-
stringSTATUS_NOT_LINKED'notLinked'Status that requires a link to not be present.
Property Summary
-
$_association protected
Cake\ORM\Association|stringThe association that should be checked.
-
$_requiredLinkState protected
stringThe link status that is required to be present in order for the check to succeed.
Method Summary
__construct() public
Constructor.
__invoke() public
Callable handler.
_aliasFields() protected
Alias fields.
_buildConditions() protected
Build conditions.
_countLinks() protected
Count links.
Method Detail
__construct() public
__construct(Cake\ORM\Association|string $association, string $requiredLinkStatus)
Constructor.
Parameters
Cake\ORM\Association|string$association-
The alias of the association that should be checked.
string$requiredLinkStatus-
The link status that is required to be present in order for the check to succeed.
__invoke() public
__invoke(Cake\Datasource\EntityInterface $entity, array<string, mixed> $options): bool
Callable handler.
Performs the actual link check.
Parameters
Cake\Datasource\EntityInterface$entity-
The entity involved in the operation.
array<string, mixed>$options-
Options passed from the rules checker.
Returns
bool_aliasFields() protected
_aliasFields(array<string> $fields, Cake\ORM\Table $source): array<string>
Alias fields.
Parameters
array<string>$fields-
The fields that should be aliased.
Cake\ORM\Table$source-
The object to use for aliasing.
Returns
array<string>_buildConditions() protected
_buildConditions(array $fields, array $values): array
Build conditions.
Parameters
array$fields-
The condition fields.
array$values-
The condition values.
Returns
array_countLinks() protected
_countLinks(Cake\ORM\Association $association, Cake\Datasource\EntityInterface $entity): int
Count links.
Parameters
Cake\ORM\Association$association-
The association for which to count links.
Cake\Datasource\EntityInterface$entity-
The entity involved in the operation.
Returns
intProperty Detail
$_association protected
The association that should be checked.
Type
Cake\ORM\Association|string$_requiredLinkState protected
The link status that is required to be present in order for the check to succeed.
Type
string© 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.Rule.LinkConstraint.html