Skip to content

Instantly share code, notes, and snippets.

@weierophinney
Created February 22, 2012 22:18
Show Gist options
  • Save weierophinney/1887839 to your computer and use it in GitHub Desktop.
Save weierophinney/1887839 to your computer and use it in GitHub Desktop.
<?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