ConditionDecorator
extends AbstractDecorator
in package
Event Condition Decorator
Use this decorator to allow your event listener to only
be invoked if the if
and/or unless
conditions pass.
Table of Contents
Properties
- $_callable : callable
- Callable
- $_options : array<string|int, mixed>
- Decorator options
Methods
- __construct() : mixed
- Constructor.
- __invoke() : mixed
- Invoke
- canTrigger() : bool
- Checks if the event is triggered for this listener.
- _call() : mixed
- Calls the decorated callable with the passed arguments.
- _evaluateCondition() : bool
- Evaluates the filter conditions
Properties
$_callable
Callable
protected
callable
$_callable
$_options
Decorator options
protected
array<string|int, mixed>
$_options
= []
Methods
__construct()
Constructor.
public
__construct(callable $callable[, array<string, mixed> $options = [] ]) : mixed
Parameters
- $callable : callable
-
Callable.
- $options : array<string, mixed> = []
-
Decorator options.
__invoke()
Invoke
public
__invoke() : mixed
Tags
canTrigger()
Checks if the event is triggered for this listener.
public
canTrigger(EventInterface $event) : bool
Parameters
- $event : EventInterface
-
Event object.
Return values
bool_call()
Calls the decorated callable with the passed arguments.
protected
_call(array<string|int, mixed> $args) : mixed
Parameters
- $args : array<string|int, mixed>
-
Arguments for the callable.
_evaluateCondition()
Evaluates the filter conditions
protected
_evaluateCondition(string $condition, EventInterface $event) : bool
Parameters
- $condition : string
-
Condition type
- $event : EventInterface
-
Event object