我成功使用 ZfcRbac 模块一年多了,但在升级到 ZF2 2.5 版后,我收到以下错误,我不知道为什么会这样,希望你能帮我理解这个问题:
已向“ZfcRbac\Guard\GuardPluginManager”类型的插件管理器请求服务“ZfcRbac\Guard\RouteGuard”,但无法检索。在此过程中引发了先前类型为“Zend\ServiceManager\Exception\ServiceNotCreatedException”的异常。顺便说一句,在父服务定位器“Zend\ServiceManager\ServiceManager”中找到了一个名为“ZfcRbac\Guard\RouteGuard”的服务:您是否忘记在您的工厂中使用 $parentLocator = $serviceLocator->getServiceLocator()代码?
这是我的堆栈跟踪:
#0 /var/lib/jenkins/jobs/site/workspace/vendor/zendframework/zend-servicemanager/src/AbstractPluginManager.php(312): Zend\ServiceManager\Exception\ServiceLocatorUsageException::fromInvalidPluginManagerRequestedServiceName(Object(ZfcRbac\Guard\GuardPluginManager), Object(Zend\ServiceManager\ServiceManager), 'ZfcRbac\Guard\R...', Object(Zend\ServiceManager\Exception\ServiceNotCreatedException))
#1 /var/lib/jenkins/jobs/site/workspace/vendor/zendframework/zend-servicemanager/src/AbstractPluginManager.php(120): Zend\ServiceManager\AbstractPluginManager->tryThrowingServiceLocatorUsageException('ZfcRbac\Guard\R...', false, Object(Zend\ServiceManager\Exception\ServiceNotCreatedException))
#2 /var/lib/jenkins/jobs/site/workspace/vendor/zf-commons/zfc-rbac/src/ZfcRbac/Factory/GuardsFactory.php(51): Zend\ServiceManager\AbstractPluginManager->get('ZfcRbac\Guard\R...', Array)
#3 [internal function]: ZfcRbac\Factory\GuardsFactory->createService(Object(Zend\ServiceManager\ServiceManager), 'zfcrbacguards', 'ZfcRbac\Guards')
#4 /var/lib/jenkins/jobs/site/workspace/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(939): call_user_func(Array, Object(Zend\ServiceManager\ServiceManager), 'zfcrbacguards', 'ZfcRbac\Guards')
#5 /var/lib/jenkins/jobs/site/workspace/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(1097): Zend\ServiceManager\ServiceManager->createServiceViaCallback(Array, 'zfcrbacguards', 'ZfcRbac\Guards')
#6 /var/lib/jenkins/jobs/site/workspace/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(638): Zend\ServiceManager\ServiceManager->createFromFactory('zfcrbacguards', 'ZfcRbac\Guards')
#7 /var/lib/jenkins/jobs/site/workspace/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(598): Zend\ServiceManager\ServiceManager->doCreate('ZfcRbac\Guards', 'zfcrbacguards')
#8 /var/lib/jenkins/jobs/site/workspace/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(530): Zend\ServiceManager\ServiceManager->create(Array)
#9 /var/lib/jenkins/jobs/site/workspace/vendor/zf-commons/zfc-rbac/src/ZfcRbac/Module.php(44): Zend\ServiceManager\ServiceManager->get('ZfcRbac\Guards')
#10 [internal function]: ZfcRbac\Module->onBootstrap(Object(Zend\Mvc\MvcEvent))
#11 /var/lib/jenkins/jobs/site/workspace/vendor/zendframework/zend-eventmanager/src/EventManager.php(444): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#12 /var/lib/jenkins/jobs/site/workspace/vendor/zendframework/zend-eventmanager/src/EventManager.php(205): Zend\EventManager\EventManager->triggerListeners('bootstrap', Object(Zend\Mvc\MvcEvent), Array)
#13 /var/lib/jenkins/jobs/site/workspace/vendor/zendframework/zend-mvc/src/Application.php(157): Zend\EventManager\EventManager->trigger('bootstrap', Object(Zend\Mvc\MvcEvent))
#14 /var/lib/jenkins/jobs/site/workspace/vendor/zendframework/zend-mvc/src/Application.php(261): Zend\Mvc\Application->bootstrap(Array)
#15 /var/lib/jenkins/jobs/site/workspace/httpdocs/index.php(33): Zend\Mvc\Application::init(Array)
#16 {main}
我正在通过作曲家自动加载器加载所有类。如果我禁用 config/application.config.php 中的模块,我会让网站正常工作。
提前致谢。