zend framework2 - Pass data to controller from Module.php
How can I pass data to controllers from Module class?
I need to pass data from onBootstrap method to all module controllers. What is the best way to do this. I can access controller using$e->getTarget()
but don't know how to pass custom data to it. Maybe controller has storage for that?
Answer
Solution:
The controller has access to the
MvcEvent
you can setup an event listener to attach arbitrary data to it and then fetch it within the controller.Module.php
Controller
@JonDay suggested an event listener which would also work well.