Zend\EventManager\EventManager::attach
Attach a listener to an event
The first argument is the event, and the next argument describes a callback that will respond to that event. A CallbackHandler instance describing the event listener combination will be returned. The last argument indicates a priority at which the event should be executed. By default, this value is 1; however, you may set it for any integer value. Higher values have higher priority (i.e., execute first). You can specify "*" for the event name. In such cases, the listener will be triggered for every event.
Signature
public function attach(string|array|ListenerAggregateInterface
$event,
[callable|int
$callback = null,
[integer
$priority = 1]] )
Parameters
$event
— object- An event or array of event names. If a ListenerAggregateInterface, proxies to {@link attachAggregate()}.
$callback
— object- If string $event provided, expects PHP callback; for a ListenerAggregateInterface $event, this will be the priority
$priority
— integer- If provided, the priority at which to register the callable
Returns
- CallbackHandler|mixed
- CallbackHandler if attaching callable (to allow later unsubscribe); mixed if attaching aggregate