\Cake\ORM\RuleExistsIn

Checks that the value provided in a field exists as the primary key of another table.

Summary

Methods
Properties
Constants
__construct()
__invoke()
No public properties found
No constants found
_fieldsAreNull()
$_fields
$_repository
$_options
N/A
No private methods found
No private properties found
N/A

Properties

$_fields

$_fields : array

The list of fields to check

Type

array

$_options

$_options : array

Options for the constructor

Type

array

Methods

__construct()

__construct(string|array  $fields, \Cake\Datasource\RepositoryInterface|\Cake\ORM\Association|string  $repository, array  $options = array()) 

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.

\Cake\Datasource\RepositoryInterface|\Cake\ORM\Association|string $repository

The repository where the field will be looked for, or the association name for the repository.

array $options

The options that modify the rules behavior. Options 'allowNullableNulls' will make the rule pass if given foreign keys are set to null. Notice: allowNullableNulls cannot pass by database columns set to NOT NULL.

__invoke()

__invoke(\Cake\Datasource\EntityInterface  $entity, array  $options) : boolean

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 repository key is required.

Throws

\RuntimeException

When the rule refers to an undefined association.

Returns

boolean

_fieldsAreNull()

_fieldsAreNull(\Cake\Datasource\EntityInterface  $entity, \Cake\ORM\Table  $source) : boolean

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

boolean