Created
February 13, 2013 09:04
-
-
Save manuakasam/4943211 to your computer and use it in GitHub Desktop.
Working initializers
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
| return array( | |
| 'invokables' => array( | |
| 'db-class-one' => 'Application\Model\DbOne', | |
| 'db-class-two' => 'Application\Model\DbTwo' | |
| ), | |
| 'factories' => array( | |
| 'Zend\Db\Adapter\Adapter' => 'Zend\Db\Adapter\AdapterServiceFactory' | |
| ), | |
| 'initializers' => array( function($instance, $sm) { | |
| if ($instance instanceof \Application\Model\DBInterface) { | |
| $instance->setDbAdapter($sm->get('Zend\Db\Adapter\Adapter')); | |
| } | |
| }) | |
| ) | |
| // DbOne implements DbInterface | |
| // Controller | |
| $this->getServiceLocator()->get('db-class-one'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment