CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 4.6 Strawberry API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 4.6
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Global
  • Cake
    • Auth
    • Cache
    • Collection
    • Command
    • Console
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Filesystem
    • Form
    • Http
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
      • Association
      • Behavior
      • Exception
      • Locator
      • Query
      • Rule
    • Routing
    • Shell
    • TestSuite
    • Utility
    • Validation
    • View

Class LinkConstraint

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

Namespace: Cake\ORM\Rule

Constants

  • string
    STATUS_LINKED ¶
    'linked'

    Status that requires a link to be present.

  • string
    STATUS_NOT_LINKED ¶
    'notLinked'

    Status that requires a link to not be present.

Property Summary

  • $_association protected
    Cake\ORM\Association|string

    The association that should be checked.

  • $_requiredLinkState protected
    string

    The 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
int

Property 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
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs