我在 中定义了一个服务Module.php
,我在其中注入了我的mail
配置,以config/autoload/global.php
这种方式定义:
public function getConfig()
{
return include __DIR__ . '/../config/module.config.php';
}
public function getServiceConfig()
{
return [
'factories' => [
'Mailer' => function($container) {
return new MailService($this->getConfig()['mail']);
},
]
];
}
但我想以 ZF3 的方式来做(我正在学习,所以我以module.config.php
这种方式定义了我的服务:
return [
'services' => [
'factories' => [
Service\MailService::class => MailServiceFactory::class
]
],
我MailServiceFactory.php
的是:
class MailServiceFactory implements FactoryInterface
{
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
return new MailService();
}
}
但是我怎样才能检索我定义的配置global.php
并将其注入工厂,这是我的服务需要的?