Zend\Mvc\Controller\AbstractController::attachDefaultListeners PHP Method

attachDefaultListeners() protected method

Register the default events for this controller
protected attachDefaultListeners ( ) : void
return void
    protected function attachDefaultListeners()
    {
        $events = $this->getEventManager();
        $events->attach(MvcEvent::EVENT_DISPATCH, [$this, 'onDispatch']);
    }

Usage Example

コード例 #1
0
 protected function attachDefaultListeners()
 {
     parent::attachDefaultListeners();
     $this->getEventManager()->attach(MvcEvent::EVENT_DISPATCH, function (MvcEvent $event) {
         $event->getTarget()->layout('layout/frontend/gallery');
     });
 }