i read that implementing: ServiceLocatorAwareInterface will inject the serviceLocator to the same class. So I got this:
Class MyModel implements ServiceLocatorAwareInterface {
protected $serviceLocator;
public function setServiceLocator(ServiceLocatorInterface $serviceLocator)
{
$this->serviceLocator = $serviceLocator;
}
public function getServiceLocator()
{
return $this->serviceLocator;
}
}
But $this->serviceLocator is always NULL
Do i have to do more than that?
You have to register your model in Service Config and retrieve it using service manager. Here is an example: