Skip to content

Instantly share code, notes, and snippets.

@juriansluiman
Created October 14, 2011 08:31
Show Gist options
  • Save juriansluiman/1286560 to your computer and use it in GitHub Desktop.
Save juriansluiman/1286560 to your computer and use it in GitHub Desktop.
IndexController with "preDispatch" event simulation
<?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