我读到实现:ServiceLocatorAwareInterface 会将 serviceLocator 注入同一个类。所以我得到了这个:
Class MyModel implements ServiceLocatorAwareInterface {
protected $serviceLocator;
public function setServiceLocator(ServiceLocatorInterface $serviceLocator)
{
$this->serviceLocator = $serviceLocator;
}
public function getServiceLocator()
{
return $this->serviceLocator;
}
}
但是 $this->serviceLocator 始终为 NULL
我还需要做更多吗?