On this page
Class ExistsIn
Checks that the value provided in a field exists as the primary key of another table.
Properties summary
- 
    
$_fieldsprotectedThe list of fields to checkarray - 
    
$_optionsprotectedOptions for the constructorarray - 
    
$_repositoryprotectedThe repository where the field will be looked forarray 
Method Summary
- 
    __construct() publicConstructor.
 - 
    __invoke() publicPerforms the existence check
 - 
    _fieldsAreNull() protectedChecks whether or not the given entity fields are nullable and null.
 
Method Detail
__construct()source public
__construct( string|array $fields , object|string $repository , array $options [] )
   Constructor.
Available option for $options is 'allowNullableNulls' flag. Set to true to accept composite foreign keys where one or more nullable columns are null.
Parameters
- 
     string|array 
$fields - The field or fields to check existence as primary key.
 - 
     object|string 
$repository - 
     
The repository where the field will be looked for, or the association name for the repository.
 - 
     array 
$optionsoptional [] - The options that modify the rules behavior.
 
__invoke()source public
__invoke( Cake\Datasource\EntityInterface $entity , array $options )
   Performs the existence check
Parameters
Cake\Datasource\EntityInterface$entity- The entity from where to extract the fields
 - 
     array 
$options - 
     
Options passed to the check, where the
repositorykey is required. 
Returns
booleanThrows
RuntimeExceptionWhen the rule refers to an undefined association.
_fieldsAreNull()source protected
_fieldsAreNull( Cake\Datasource\EntityInterface $entity , Cake\ORM\Table $source )
   Checks whether or not the given entity fields are nullable and null.
Parameters
Cake\Datasource\EntityInterface$entity- The entity to check.
 Cake\ORM\Table$source- The table to use schema from.
 
Returns
booleanProperties detail
© 2005–2017 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/3.3/class-Cake.ORM.Rule.ExistsIn.html