如何在Zend Framework 3中调用IndexControllerFactory(或任何工厂)并创建IndexController?

时间:2019-06-19 10:11:56

标签: zend-framework frameworks

我了解到module.config.php文件中有“工厂”键,该键可能正在读取:

`'controllers' => [
'factories' => [
        IndexController::class => IndexControllerFactory::class
    ],

],  `

那么如何以及何时创建IndexControllerFactory?同样与以下代码段有关,如何以及何时调用__invoke方法:

class IndexControllerFactory extends MultibyteControllerFactory implements FactoryInterface
{
    public function __invoke(ContainerInterface $container,
        $requestedName, array $options = null)
    {

        $entityManager = $container->get('doctrine.entitymanager.orm_default');

        return new IndexController($entityManager);
    }
}

0 个答案:

没有答案