Created
May 18, 2012 17:31
-
-
Save sinamiandashti/2726585 to your computer and use it in GitHub Desktop.
problem bootstrap evend zf2
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 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