Skip to content

Instantly share code, notes, and snippets.

@PEM-FR
Created June 28, 2012 08:49
Show Gist options
  • Save PEM-FR/3009982 to your computer and use it in GitHub Desktop.
Save PEM-FR/3009982 to your computer and use it in GitHub Desktop.
dep injection
protected $_serviceFactory;
/**
*You can inject a mock factory here for unit testing
*
*/
public function setServiceFactory(ServiceFactory $serviceFactory)
{
$this->_serviceFactory = $serviceFactory;
}
/**
*@returns Module\Service\A
*/
private function _getServiceA()
{
if (null != $this->_serviceA) {
$this->_serviceA = $this->_serviceFactory->get('module_service_a');
}
return $this->_serviceA;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment