Skip to content

Instantly share code, notes, and snippets.

@manuakasam
Created April 2, 2013 15:41
Show Gist options
  • Select an option

  • Save manuakasam/5293218 to your computer and use it in GitHub Desktop.

Select an option

Save manuakasam/5293218 to your computer and use it in GitHub Desktop.
Constructor Injection Barebone
someAction() {
$model = $this->getServiceLocator()->get('my-model');
}
class Model {
public function __construct(ServiceManager $sm) {
$this->sm = $sm;
}
}
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