Class LinkConstraint
Checks whether links to a given association exist / do not exist.
Constants
Property Summary
- 
        $_association protectedCake\ORM\Association|stringThe association that should be checked. 
- 
        $_requiredLinkState protectedstringThe link status that is required to be present in order for the check to succeed. 
Method Summary
- 
          __construct() publicConstructor. 
- 
          __invoke() publicCallable handler. 
- 
          _aliasFields() protectedAlias fields. 
- 
          _buildConditions() protectedBuild conditions. 
- 
          _countLinks() protectedCount 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 $options): boolCallable handler.
Performs the actual link check.
Parameters
- 
                Cake\Datasource\EntityInterface$entity
- The entity involved in the operation. 
- 
                array$options
- Options passed from the rules checker. 
Returns
boolWhether the check was successful.
_aliasFields() ¶ protected
_aliasFields(array $fields, Cake\ORM\Table $source): arrayAlias fields.
Parameters
- 
                array$fields
- The fields that should be aliased. 
- 
                Cake\ORM\Table$source
- The object to use for aliasing. 
Returns
arrayThe aliased fields
_buildConditions() ¶ protected
_buildConditions(array $fields, array $values): arrayBuild conditions.
Parameters
- 
                array$fields
- The condition fields. 
- 
                array$values
- The condition values. 
Returns
arrayA conditions array combined from the passed fields and values.
_countLinks() ¶ protected
_countLinks(Cake\ORM\Association $association, Cake\Datasource\EntityInterface $entity): intCount links.
Parameters
- 
                Cake\ORM\Association$association
- The association for which to count links. 
- 
                Cake\Datasource\EntityInterface$entity
- The entity involved in the operation. 
Returns
intThe number of links.
