我有一个自定义身份验证服务,在 ZF2 中我按如下方式访问它:
Application/view/layout/layout.phtml
$authenticationService = $this->getHelperPluginManager()
->getServiceLocator()
->get('AuthenticationService');
$currentIdentity = $authenticationService->getIdentity();
现在Zend\ServiceManager#getServiceLocator()
已弃用。
如何在 ZF3 的视图脚本(或在这种情况下为布局中的具体)中获得可用的服务?