Skip to content

Instantly share code, notes, and snippets.

@slopjong
Forked from manuakasam/gist:5263154
Created March 28, 2013 13:54
Show Gist options
  • Save slopjong/5263286 to your computer and use it in GitHub Desktop.
Save slopjong/5263286 to your computer and use it in GitHub Desktop.
public function getServiceConfig()
{
return array(
'factories' => array(
'my-model' => function($sm) {
$model = new \My\Model($sm);
return $model;
}
)
);
}
class Model {
protected $serviceManager;
public function __construct(ServiceManager $serviceManager) {
$this->serviceManager = $serviceManager;
}
public function someFunction() {
$dependency = $this->serviceManager->get('my-dependency');
}
}
someControllerAction() {
$model = $this->getServiceLocator()->get('my-model');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment