Zend framework 2 preDispatch

Categories: howto

Как сделать preDispatch и postDispatch actions в Zend Framework 2 ? код ниже

namespace Application\Controller;
use Zend\Mvc\Controller\ActionController
class IndexController extends ActionController
    public function indexAction()
        return array();
    protected function attachDefaultListeners()
        $events = $this->events();
        $events->attach('dispatch', array($this, 'preDispatch'), 100);
        $events->attach('dispatch', array($this, 'postDispatch'), -100);
    public function preDispatch (MvcEvent $e)
        // Called before self::indexAction()
    public function postDispatch (MvcEvent $e)
        // Called after self::indexAction()

“100” и “-100” это порядок запуска действий.

No webmentions were found.

Comment with Disqus

Comment with an Email

No comments here yet Write here gently

Comment with Talkyard

Comments powered by Talkyard.