草庐IT

ControllerPlugin

全部标签

php - ControllerPlugin 类中的 ZF2 getServiceLocator

我正在尝试在插件类中获取服务定位器/实体管理器,我该如何获取它。在我的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