src/Controller/Index.php
public function preDispatch(MvcEvent $event)
    {
        $this->layout()->setVariable('lang', $this->params('lang'));

        $p       = $this->params()->fromQuery('p');
        $request = $this->getRequest();

        if ($p && $request->isXmlHttpRequest()) {
            $routeMatch = $event->getRouteMatch();
            $routeMatch->setParam('action', $p);
            $response = $this->getResponse();
            $response->getHeaders()
                     ->addHeaderLine('Content-Type', 'application/json')
                     ->addHeaderLine('Content-Encoding', 'utf8');
        }
    }
public function preDispatch(MvcEvent $event)
    {
        $this->layout()->setVariable('lang', $this->params('lang'));

        $p       = $this->params()->fromQuery('p');
        $request = $this->getRequest();

        if ($p && $request->isXmlHttpRequest()) {
            $routeMatch = $event->getRouteMatch();
            $routeMatch->setParam('action', $p);
            $response = $this->getResponse();
            $response->getHeaders()
                     ->addHeaderLine('Content-Type', 'application/json')
                     ->addHeaderLine('Content-Encoding', 'utf8');
        }
    }
public function preDispatch ( MvcEvent $ event ) { $ this -> layout ( ) -> setVariable ( 'lang' , $ this -> params ( 'lang' ) ) ; $ p = $ this -> params ( ) -> fromQuery ( 'p' ) ; $ request = $ this -> getRequest ( ) ; if ( $ p && $ request -> isXmlHttpRequest ( ) ) { $ routeMatch = $ event -> getRouteMatch ( ) ; $ routeMatch -> setParam ( 'action' , $ p ) ; $ response = $ this -> getResponse ( ) ; $ response -> getHeaders ( ) -> addHeaderLine ( 'Content-Type' , 'application/json' ) -> addHeaderLine ( 'Content-Encoding' , 'utf8' ) ; } }
Hook for custom preDispatch event.

@param MvcEvent $event
Hook for custom preDispatch event .