Created
May 30, 2012 20:49
-
-
Save basz/2838880 to your computer and use it in GitHub Desktop.
addInitializer example
This file contains hidden or 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
| 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