Class ConditionDecorator
Event Condition Decorator
Use this decorator to allow your event listener to only
be invoked if the if and/or unless conditions pass.
Namespace: Cake\Event\Decorator
Property Summary
-
$callable protected
callableCallable
Method Summary
-
__construct() public
Constructor.
-
__invoke() public
Invoke
-
call() protected
Calls the decorated callable with the passed arguments.
-
canTrigger() public
Checks if the event is triggered for this listener.
-
evaluateCondition() protected
Evaluates the filter conditions
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
mixedcanTrigger() ¶ public
canTrigger(Cake\Event\EventInterface<TSubject> $event): bool
Checks if the event is triggered for this listener.
Templates
TSubject
of object Parameters
-
Cake\Event\EventInterface<TSubject>$event Event object.
Returns
boolevaluateCondition() ¶ protected
evaluateCondition(string $condition, Cake\Event\EventInterface<TSubject> $event): bool
Evaluates the filter conditions
Templates
TSubject
of object Parameters
-
string$condition Condition type
-
Cake\Event\EventInterface<TSubject>$event Event object
Returns
bool