class CustomSawException extends Exception implements ServiceLocatorAwareInterface, SawExceptionInterface
{
protected $serviceLocator;
public function test(){
$this->serviceLocator->get('SomeThing');
}
/**
* Set service locator
*
* @param ServiceLocatorInterface $serviceLocator
*/
public function setServiceLocator(ServiceLocatorInterface $serviceLocator)
{
$this->serviceLocator = $serviceLocator;
}
/**
* Get service locator
*
* @return ServiceLocatorInterface
*/
public function getServiceLocator()
{
return $this->serviceLocator;
}
The exception that is thrown for this is:
call of get() on null
I could not figure out why it is throwing exception?
ServiceLocatorAwareInterface
should have injected the ServiceLocator
?
I am not so sure about that, in the latest versions of ZF2 this interface is deprecated.
Read also this post on GitHub or this stackoverflow question for more information.