ZF2-131: 'dispatch.pre' and '' not triggered within ActionController class

Issue Type: Bug Created: 2012-01-07T16:39:22.000+0000 Last Updated: 2012-01-08T09:08:54.000+0000 Status: Resolved Fix version(s): Reporter: Pascal Rota (erasertwo) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend\Mvc\Controller

Related issues: Attachments:



I tried to use the 'dispatch.pre' and '' events of the ActionController in my specialized Constroller class without any luck. It seems that both events are never triggered (or I did not find the place where they are) and thus both events goes into nothing.

My suggestion is to add $this->events()->trigger('dispatch.pre', $e); into the ActionController::dispatch function to fix it.

Here is my code:

class AdminController extends ActionController {


public function __construct() { $events = $this->events(); $events->attach('dispatch.pre' , array($this, 'preDispatch')); }


public function preDispatch() { echo 'preDispatch called'; }

... }

Regards, Pascal


Posted by Matthew Weier O'Phinney (matthew) on 2012-01-07T23:44:14.000+0000

There are no "dispatch.pre" or "" events. Instead, use the priority system -- add a final argument to attach() indicating the priority at which you want the event triggered. Higher priority values trigger earlier (pre), while negative priority values trigger later (post). Default priority, and the priority of the default handler, is 1.

As an example:

<pre class="highlight">
$events->attach('dispatch', array($this, 'preDispatch'), 100);

Posted by Pascal Rota (erasertwo) on 2012-01-08T09:08:54.000+0000


Thanks for the hint about the priority within the event dispatcher.

Nevertheless, I think that the comment of the ActionController::dispatch function should be amended to prevent further confusion.

Regards, Pascal

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.