Skip to content

Instantly share code, notes, and snippets.

@weierophinney
Created December 5, 2011 22:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weierophinney/1435714 to your computer and use it in GitHub Desktop.
Save weierophinney/1435714 to your computer and use it in GitHub Desktop.
Example listener for changing layouts
<?php
namespace Guest;
use Zend\EventManager\StaticEventManager;
class Module
{
public function init()
{
$events = StaticEventManager::getInstance();
$events->attach('bootstrap', 'bootstrap', array($this, 'bootstrap'));
}
public function bootstrap($e)
{
$app = $e->getParam('application');
$app->events()->attach('dispatch', array($this, 'layout', -900));
}
public function layout($e)
{
$routeMatch = $e->getRouteMatch();
$route = $routeMatch->getMatchedRouteName();
if (in_array($route, $someListOfRoutes)) {
// hint to listener about new layout
}
}
}
<?php
namespace Guest;
use Zend\EventManager\StaticEventManager;
class Module
{
public function init()
{
$events = StaticEventManager::getInstance();
$events->attach('bootstrap', 'bootstrap', array($this, 'bootstrap'));
}
public function bootstrap($e)
{
$app = $e->getParam('application');
$app->events()->attach('dispatch', array($this, 'layout', -900));
}
public function layout($e)
{
$routeMatch = $e->getRouteMatch();
$route = $routeMatch->getMatchedRouteName();
if (in_array($route, $someListOfRoutes)) {
// hint to listener about new layout
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment