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
callable
Callable
-
$_options protected
array
Decorator options
Method Summary
-
__construct() public
Constructor.
-
__invoke() public
Invoke
-
_call() protected
Calls the decorated callable with the passed arguments.
-
_evaluateCondition() protected
Evaluates the filter conditions
-
canTrigger() public
Checks if the event is triggered for this listener.
Method Detail
__construct() ¶ public
__construct(callable $callable, array $options = [])
Constructor.
Parameters
-
callable
$callable Callable.
-
array
$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
_evaluateCondition() ¶ protected
_evaluateCondition(string $condition, Cake\Event\EventInterface $event): bool
Evaluates the filter conditions
Parameters
-
string
$condition Condition type
-
Cake\Event\EventInterface
$event Event object
Returns
bool
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