Skip to content

Instantly share code, notes, and snippets.

@sinamiandashti
Created May 18, 2012 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sinamiandashti/2726585 to your computer and use it in GitHub Desktop.
Save sinamiandashti/2726585 to your computer and use it in GitHub Desktop.
problem bootstrap evend zf2
<?php
namespace Accounting;
use Zend\Module\Manager,
Zend\EventManager\Event,
Zend\EventManager\StaticEventManager,
Zend\Module\Consumer\AutoloaderProvider;
class Module implements AutoloaderProvider {
public function init(Manager $moduleManager) {
$sharedEvents = $moduleManager->events()->getSharedManager();
$sharedEvents->attach('bootstrap', 'bootstrap', array($this,
'initializeView'), 100);
$sharedEvents->attach('Accounting', 'dispatch', function($e) {
$controller = $e->getTarget();
$route = $controller->getEvent()->getRouteMatch();
$viewModel = $controller->getEvent()->getViewModel();
$variables = $viewModel->getVariables();
if (false === isset($variables['controller'])) {
$viewModel->setVariable('controller', $route->getParam('controller'));
}
if (false === isset($variables['action'])) {
$viewModel->setVariable('action', $route->getParam('action'));
}
}, 100);
}
public function getAutoloaderConfig() {
return array(
'Zend\Loader\ClassMapAutoloader' => array(
__DIR__ . '/autoload_classmap.php',
),
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}
public function getConfig() {
return include __DIR__ . '/config/module.config.php';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment