0

I am creating an application in zf2.

I have a Plugin (MyModule\Controller\Plugin\MyPlugin) that I can call in my controller without any problem.

I would like to be able to call it from a mapper (like it was possible in zf1 doing getStaticHelper(). I found that it is possible to get it in the view by doing Zend_Controller_Front::getInstance() and then call the plugin but this doesn't work in the mapper.

Is that possible? Thanks!

4

1 回答 1

0

我认为您必须在 module.config.php 中添加如下内容:

'controller_plugins' => array(
'invokables' => array(
    'userauthentication' => 'User\Controller\Plugin\UserAuthentication',
),

),

然后你应该可以从任何控制器调用它:

$this->userAuthentication()->getAuthService()->hasIdentity();
于 2012-11-09T15:30:17.400 回答