title: Zend Framework 2 dispatch event doesn't run before action
body: <p><br/>
  I need some help. I want to run a method in Zend Framework 2 before the controller's action runs. I putted my method in Module.php's onBootstrap, but it doesn't run before action initated.</p>
  
  <p>In Module.php:</p>
  
  <pre><code>public function onBootstrap(MvcEvent $e)
  {
      $eventManager        = $e-&gt;getApplication()-&gt;getEventManager();
      $moduleRouteListener = new ModuleRouteListener();
      $moduleRouteListener-&gt;attach($eventManager);
  
      $app  = $e-&gt;getApplication();
      $em = $app-&gt;getEventManager();
  
      $em-&gt;attach(MvcEvent::EVENT_DISPATCH, function($e) {
          $controller = $e-&gt;getTarget();
          $controller-&gt;Init();
      });
  }
  </code></pre>
  
  <p>I want to run the Init() method to my Adapter would be initialized before action runs but it didn't work and I always get this message:<br/>
  <strong>Catchable fatal error: Argument 1 passed to Application\Model\Members::__construct()    must be an instance of Zend\Db\Adapter\Adapter, null given, called in PATH\module\Application\src\Application\Controller\AdminController.php on line 39 and defined in PATH\module\Application\src\Application\Model\Members.php on line 17</strong></p>
  
  <p>The members class is in the action which should run and its __construct need to have a valid Adapter object that should be initialized in Init() method.</p>
  
  <p>Could anyone help me?
  Thanks a lot!</p>