call controller action from module.php in zf2 onBootstrap

613 views Asked by At

i am tracking the api error codes from module.php file. I want to pass the data to controller or want to create an adapter in module.php file. Please suggest me different ways so that i can track and store error codes from module.php file itself.

i only want to exe a controller action and not want to redirect from module.php

Thanks in advance !

     public function handleError(MvcEvent $evt)
     {
        $application  = $evt->getApplication();
        $eventManager = $application->getEventManager()->getSharedManager();
        $eventManager->attach('Zend\Mvc\Controller\ApiTrackController', 'dispatch', function($event) {
        $controller = $event->getTarget();

        // Set public property
        $controller->trackapi = 'trackapi';//ActionName
        });//attach ends here.
    }//Handle error function ends.
0

There are 0 answers