As in the tutorial "MVC + Events + Modules: the new architecture of ZF2" by Enrico Zimuel shown, the basic ZF2 MVC events structure looks like this:
ZF MVC Auth extends the adds the basic MVC flow, adding four events to it (EVENT_AUTHENTICATION
, EVENT_AUTHENTICATION_POST
, EVENT_AUTHORIZATION
, EVENT_AUTHORIZATION_POST
).
Now I'm reading the Apigility "Advanced Authentication and Authorization" documentation, that says:
In order to achieve integration to the ZF2 MVC lifecycle for authentication,
zf-mvc-auth
wires in 4 listeners that then propagate their own events. Each of these listeners are registered within the eventMvcEvent::EVENT_ROUTE
at different priorities.
Two point are unclear for me:
"Each of these listeners are registered within the event MvcEvent::EVENT_ROUTE
" -- "Nested events"? What does this mean?
"within the event MvcEvent::EVENT_ROUTE
at different priorities" -- Is the events priorities hierarchy "nested" / not straight-line? Is it multidimensional?
You would attach listeners to or on events; these listeners would be ordered by their priority.
When the event is triggered (say event MvcEvent::EVENT_ROUTE
) the listeners that are registered would execute one-by-one, starting with the listener with the highest priority through to the lowest.
"Nested events" or "propagate their own events" would be where one of these listeners triggers another event. An example of this is the listener for rendering, \Zend\View\Http\DefaultRenderingStrategy::render()
, where MvcEvent::EVENT_RENDER_ERROR
is triggered when a rendering error occurs.