【发布时间】:2017-06-29 08:19:25
【问题描述】:
我知道这已在其他线程中广泛介绍,但我正在努力研究如何在 ZF3 控制器中从 ZF2 控制器复制 $this->getServiceLocator() 的效果。
我尝试使用在此处和其他地方找到的各种其他答案和教程创建工厂,但最后都弄得一团糟,所以我粘贴了我开始时的代码希望有人能指出我正确的方向吗?
来自/module/Application/config/module.config.php
'controllers' => [
'factories' => [
Controller\IndexController::class => InvokableFactory::class,
],
],
来自/module/Application/src/Controller/IndexController.php
public function __construct() {
$this->objectManager = $this->getServiceLocator()->get('Doctrine\ORM\EntityManager');
$this->trust = new Trust;
}
【问题讨论】:
标签: php zend-framework-mvc zend-framework3 zend-servicemanager