Skip to content

Instantly share code, notes, and snippets.

@basz
Created May 30, 2012 20:49
Show Gist options
  • Select an option

  • Save basz/2838880 to your computer and use it in GitHub Desktop.

Select an option

Save basz/2838880 to your computer and use it in GitHub Desktop.
addInitializer example
public function onBootstrap(\Zend\Mvc\MvcEvent $e)
{
$sm = $e->getApplication()->getServiceManager();
$sm->get('ControllerLoader')->addInitializer(function($instance) use ($sm) {
if ($instance instanceof \Zend\Log\LoggerAwareInterface) {
if ($instance instanceof \Application\Controller\PaypalController) {
$logger = $sm->get(__NAMESPACE__ . '.paypal.logger');
}
if ($instance instanceof \Application\Controller\StoreController) {
$logger = $sm->get(__NAMESPACE__ . '.download.logger');
}
if ($logger) {
$instance->setLogger($logger);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment