Created
February 22, 2012 22:18
-
-
Save weierophinney/1887839 to your computer and use it in GitHub Desktop.
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 FooModule; | |
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'); | |
$this->config = $app->getConfig(); | |
$app->events()->attach('dispatch', array($this, 'changeLayout'), 100); | |
} | |
public function changeLayout($e) | |
{ | |
$routeMatch = $e->getRouteMatch(); | |
if ($routeMatch->getMatchedRouteName() !== $someCriteriaHere) { | |
return; | |
} | |
$viewModel = $e->getViewModel(); | |
$viewModel->setTemplate($this->config['some']['key']['from']['config']); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment