unlikelysource.com

Are there any code examples of using identifiers with EventManager? How are identifiers useful and how are they used?


Are there any code examples of using identifiers with EventManager? How are identifiers useful and how are they used?

A: Identifiers are a way to create communication between an individual
EventManager instance and the SharedEventManager. This allows you to
connect a listener to an event without having direct access to the given
EventManager instance or the object that composes it.

As an example, consider the various view listeners in ZF2 itself. As an
example, there's one that will take a returned array from a controller,
and create a ViewModel out of it. This listens on the
"Zend\Stdlib\DispatchableInterface" context -- which means that any
object that defines that context will trigger that listener if it
triggers the appropriate event.

BACK

© 2018 unlikelysource.com | all rights reserved