Created
October 14, 2011 08:31
-
-
Save juriansluiman/1286560 to your computer and use it in GitHub Desktop.
IndexController with "preDispatch" event simulation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Application\Controller; | |
use Zend\Mvc\Controller\ActionController | |
Zend\Mvc\MvcEvent; | |
class IndexController extends ActionController | |
{ | |
public function indexAction() | |
{ | |
return array(); | |
} | |
protected function attachDefaultListeners() | |
{ | |
parent::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() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment