W3cubDocs

/CakePHP 4.4

Class SubjectFilterDecorator

Event Subject Filter Decorator

Use this decorator to allow your event listener to only be invoked if event subject matches the allowedSubject option.

The allowedSubject option can be a list of class names, if you want to check multiple classes.

Property Summary

Method Summary

Method Detail

__construct() public

__construct(callable $callable, array<string, mixed> $options = [])

Constructor.

Parameters

callable $callable

Callable.

array<string, mixed> $options optional

Decorator options.

__invoke() public

__invoke(): mixed

Invoke

Returns

mixed

_call() protected

_call(array $args): mixed

Calls the decorated callable with the passed arguments.

Parameters

array $args

Arguments for the callable.

Returns

mixed

canTrigger() public

canTrigger(Cake\Event\EventInterface $event): bool

Checks if the event is triggered for this listener.

Parameters

Cake\Event\EventInterface $event

Event object.

Returns

bool

Property Detail

$_callable protected

Callable

Type

callable

$_options protected

Decorator options

Type

array

© 2005–present 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/4.4/class-Cake.Event.Decorator.SubjectFilterDecorator.html