Last active
December 26, 2015 07:49
-
-
Save ThaDafinser/7117455 to your computer and use it in GitHub Desktop.
Proposal for ZF2
This file contains 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
<?php | |
namespace Zend\ServiceManager; | |
class AbstractServiceManagerAware implements ServiceLocatorAwareInterface | |
{ | |
/** | |
* | |
* @var ServiceLocatorInterface | |
*/ | |
protected $serviceLocator; | |
/** | |
* Set serviceManager instance | |
* | |
* @param ServiceLocatorInterface $serviceLocator | |
* @return void | |
*/ | |
public function setServiceLocator(ServiceLocatorInterface $serviceLocator) | |
{ | |
$this->serviceLocator = $serviceLocator; | |
return $this; | |
} | |
/** | |
* Retrieve serviceManager instance | |
* | |
* @return ServiceLocatorInterface | |
*/ | |
public function getServiceLocator() | |
{ | |
return $this->serviceLocator; | |
} | |
} |
This file contains 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
<?php | |
namespace MyModule\Services; | |
use Zend\ServiceManager\AbstractServiceManagerAware; | |
class MyService extends AbstractServiceManagerAware | |
{ | |
public function doSomething(){ | |
$otherSerice = $this->getServiceLocator()->get('myOtherSerice'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment