我正在尝试访问模型中的getServiceLocator函数。它在Controller中工作,但是当我将它移动到模型中时,我在尝试访问时得到NULL。Calltoamemberfunctionget()onnull似乎下面的链接提供了类似的解决方案,但我在实现时遇到了麻烦Useanothermoduleinourcustomhelperinzendframework2下面是我试图在模型中运行的代码。useZend\ServiceManager\ServiceLocatorAwareInterface;useZend\ServiceManager\ServiceLocatorInterf
我这辈子都无法让$this->getServiceLocator()在我的Controller中工作。我已经阅读并尝试了一切。我猜我错过了什么??这是一些代码。namespaceLogin\Controller;useZend\Mvc\Controller\AbstractActionController;useZend\Session\ContainerasSessionContainer;useZend\Session\SessionManager;useZend\View\Model\ViewModel;useZend\Mvc\Controller;useLogin\Model\
我正在尝试在插件类中获取服务定位器/实体管理器,我该如何获取它。在我的Controller中,我是这样得到它的。publicfunctiongetEntityManager(){if(null===$this->em){$this->em=$this->getServiceLocator()->get('doctrine.entitymanager.orm_default');}return$this->em;}publicfunctionsetEntityManager(EntityManager$em){$this->em=$em;}但在插件类中,我在$this->getServi