我有一個代碼,在頁面以這種方式呈現在Module.php
之前執行。控制器必須實現InjectApplicationEventInterface
$eventManager->attach(MvcEvent::EVENT_RENDER, function(MvcEvent $event) {
/** @var ServiceManager $sm */
$sm = $event->getParam('application')->getServiceManager();
$logger = $sm->get(LogService::class)->getLogger();
$themeResolver = $sm->get(ThemeResolveService::class);
$df = $sm->get(DataFetchService::class);
$params = $sm->get('ControllerPluginManager')->get('params');
$security = $sm->get(SecurityService::class);
try {
$cleanedParams = $security->clean($params->fromRoute());
} catch (\Exception $e) {
echo $e->getMessage();
$logger->info($e->getMessage());
die();
}
/** theme resolving code **/
}
這個問題我已經是這一行:
$cleanedParams = $security->clean($params->fromRoute());
$params->fromRoute()
作品時代的大多數,但有時當我打電話從第三方API我的申請,我得到這個錯誤。
Controllers must implement Zend\Mvc\InjectApplicationEventInterface to use this plugin
我沒有看到任何東西,是調用不同。我只需要澄清這個錯誤代表什麼,所以如果我需要改變應用程序的設計,我應該這樣做。