Created
December 5, 2011 22:34
-
-
Save weierophinney/1435714 to your computer and use it in GitHub Desktop.
Example listener for changing layouts
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 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 | |
} | |
} | |
} |
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 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