I have a code that executes before page is rendered in Module.php
like this.
$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 **/
}
The problem i have is with this line:
$cleanedParams = $security->clean($params->fromRoute());
$params->fromRoute()
works most of the times but sometimes when i call my application from 3rd party api i get this error.
Controllers must implement Zend\Mvc\InjectApplicationEventInterface to use this plugin
I don't see anything that is different in calls. I just need a clarification what this error represents so if i need to change the design of application, i should do so.