duande3134
2015-08-23 10:05
浏览 73
已采纳

ZF2 - 如何在Module.php中检索控制器实例?

I am implementing a login widget via a view helper. I need to pass the instance of my authentication controller when creating the instance of the widget:

public function getViewHelperConfig()
{
    return array(
        'factories' => array(
            'loginWidget' => function (???) {
                $authController = ???
                return new \Application\View\Helper\LoginWidget($authController);
            }
        )
    );
}

The authentication controller is declared in the module.config.php:

'controllers' => array(
    'invokables' => array(
        'Main\Controller\Index' => 'Main\Controller\IndexController',
        'Main\Controller\Auth'    => 'Main\Controller\AuthController'
    ),
),

How can I proceed?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题