Created
April 2, 2013 15:41
-
-
Save manuakasam/5293218 to your computer and use it in GitHub Desktop.
Constructor Injection Barebone
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
| someAction() { | |
| $model = $this->getServiceLocator()->get('my-model'); | |
| } |
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
| class Model { | |
| public function __construct(ServiceManager $sm) { | |
| $this->sm = $sm; | |
| } | |
| } |
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
| getServiceConfig() { | |
| return array('factories'=>array( | |
| 'my-model' => function($sm) { | |
| $model = new Model($sm); | |
| return $model; | |
| } | |
| )); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment