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.
Namespace: Cake\Event\Decorator
Property Summary
-
$_callable protected
callable
Callable
-
$_options protected
array
Decorator options
Method Summary
-
__construct() public
Constructor.
-
__invoke() public
-
_call() protected
Calls the decorated callable with the passed arguments.
-
canTrigger() public
Checks if the event is triggered for this listener.
Method Detail
__construct() ¶ public
__construct(callable $callable, array<string, mixed> $options = [])
Constructor.
Parameters
-
callable
$callable Callable.
-
array<string, mixed>
$options optional Decorator options.
_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<TSubject> $event): bool
Checks if the event is triggered for this listener.
Parameters
-
Cake\Event\EventInterface<TSubject>
$event Event object.
Returns
bool