laminas/laminas-eventmanager
Laminas EventManager provides a flexible event and listener system for PHP applications. Attach listeners, trigger events, manage priorities, and use shared event managers to coordinate decoupled components across your app.
Sometimes you'll want to attach the same listener to all events of a given instance — or potentially, with a shared event collection, all contexts.
To attach to all events on a given EventManager instance, you can use the
wildcard event, *:
$events = new EventManager();
$events->attach('*', $listener);
Note that if you specify a priority, that priority will be used for this listener for any event triggered.
What the above specifies is that any event triggered by the event manager instance will result in notification of this particular listener.
Using the SharedEventManager, you can indicate that you want to attach to all
events of a given identifier, a single named event across all identifiers, or
all events on all identifiers.
$sharedEvents = new SharedEventManager();
// Attach to all events on the context "foo"
$sharedEvents->attach('foo', '*', $listener);
// Attach to the "foo" event of any context:
$sharedEvents->attach('*', 'foo', $listener);
// Attach to all events on all contexts:
$sharedEvents->attach('*', '*', $listener);
Note that if you specify a priority, that priority will be used for all events specified.
How can I help you explore Laravel packages today?