工厂没有被加载ZF2 - 缺少参数1
我有内Module/src/Module/Service/Factory/CourseServiceFactory.php
工厂没有被加载ZF2 - 缺少参数1
工厂我在module.config.php
如下定义的这家工厂:
'service_manager' => array(
'factories' => array(
'CourseServiceFactory' => 'Module\Service\Factory\CourseServiceFactory',
),
),
但是这家工厂没有被调用时加载该应用程序,我收到此错误:
Warning: Missing argument 1 for Module\Service\CourseService::__construct(),
这是怎么我的CourseServiceFactory.php看起来像:
public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = $serviceLocator->get('config');
return new CourseService($config);
}
任何人都知道什么是错的?
我怀疑你没有实现工厂接口,导致服务加载器被注入构造函数。
确保您的工厂工具:
的Zend \的ServiceManager \ FactoryInterface
见例如工厂里
https://framework.zend.com/manual/2.4/en/in-depth-guide/services-and-servicemanager.html
我在工厂实施工厂界面 –
可以发布完整的工厂代码吗 – Andrew
如何调用服务定位器是什么样子? – akond
什么是你的__constructor(), Module \ Service \ CourseService :: __ construct(), –
@akond的参数我很抱歉你打电话给服务定位器是什么意思?一旦你在module.config.php中定义它们,工厂就不会加载Bootstrap了吗? –