Fr3nch13/CakePHP Utilities

LinkConstraint
in package

Checks whether links to a given association exist / do not exist.

Table of Contents

Constants

STATUS_LINKED  = 'linked'
Status that requires a link to be present.
STATUS_NOT_LINKED  = 'notLinked'
Status that requires a link to not be present.

Properties

$_association  : Association|string
The association that should be checked.
$_requiredLinkState  : string
The link status that is required to be present in order for the check to succeed.

Methods

__construct()  : mixed
Constructor.
__invoke()  : bool
Callable handler.
_aliasFields()  : array<string|int, string>
Alias fields.
_buildConditions()  : array<string|int, mixed>
Build conditions.
_countLinks()  : int
Count links.

Constants

STATUS_LINKED

Status that requires a link to be present.

public string STATUS_LINKED = 'linked'

STATUS_NOT_LINKED

Status that requires a link to not be present.

public string STATUS_NOT_LINKED = 'notLinked'

Properties

$_requiredLinkState

The link status that is required to be present in order for the check to succeed.

protected string $_requiredLinkState

Methods

__construct()

Constructor.

public __construct(Association|string $association, string $requiredLinkStatus) : mixed
Parameters
$association : Association|string

The alias of the association that should be checked.

$requiredLinkStatus : string

The link status that is required to be present in order for the check to succeed.

__invoke()

Callable handler.

public __invoke(EntityInterface $entity, array<string, mixed> $options) : bool

Performs the actual link check.

Parameters
$entity : EntityInterface

The entity involved in the operation.

$options : array<string, mixed>

Options passed from the rules checker.

Return values
bool

Whether the check was successful.

_aliasFields()

Alias fields.

protected _aliasFields(array<string|int, string> $fields, Table $source) : array<string|int, string>
Parameters
$fields : array<string|int, string>

The fields that should be aliased.

$source : Table

The object to use for aliasing.

Return values
array<string|int, string>

The aliased fields

_buildConditions()

Build conditions.

protected _buildConditions(array<string|int, mixed> $fields, array<string|int, mixed> $values) : array<string|int, mixed>
Parameters
$fields : array<string|int, mixed>

The condition fields.

$values : array<string|int, mixed>

The condition values.

Return values
array<string|int, mixed>

A conditions array combined from the passed fields and values.


        
On this page

Search results