public function onKernelController(FilterControllerEvent $event)
    {
        $controller = $event->getController();
        /**
         * $controller passed can be either a class or a Closure. This is not usual in Symfony2 but it may happen.
         * If it is a class, it comes in array format
         */
        if (!is_array($controller))
        {
            return;
        }
        $fullpath = $event->getRequest()->get('fullpath');
        if ($fullpath != '' && $fullpath[mb_strlen($fullpath) - 1] == '/')
        {
            $fullpath = mb_substr($fullpath, 0, -1);
        }
        if (isset($controller[0]))
        {
            if ($controller[0] instanceof FrontPageController)
            {
                if (!($this->page = $this->doctrine->getRepository('FulgurioLightCMSBundle:Page')->findOneBy(array('fullpath' => $fullpath))))
                {
                    throw new NotFoundHttpException();
                }
                if ($this->page->getStatus() === 'draft' && !(
                         $this->securityContext->isGranted('ROLE_ADMIN')
                         && !is_null($event->getRequest()->server->get('HTTP_REFERER'))
                ))
                {
                    throw new NotFoundHttpException();
                }
                //@todo : check access
                $models = $this->kernel->getContainer()->getParameter('fulgurio_light_cms.models');
                if (isset($models[$this->page->getModel()]['front']['controller']))
                {
                    $controller = $this->getController($models[$this->page->getModel()]['front']['controller']);
                    $controller[0]->setContainer($this->kernel->getContainer());
                    $event->setController($controller);
                }
                if (method_exists($controller[0], 'setPage'))
                {
                    $controller[0]->setPage($this->page);
                }
            }
        }
    }
public function onKernelController(FilterControllerEvent $event)
    {
        $controller = $event->getController();
        /**
         * $controller passed can be either a class or a Closure. This is not usual in Symfony2 but it may happen.
         * If it is a class, it comes in array format
         */
        if (!is_array($controller))
        {
            return;
        }
        $fullpath = $event->getRequest()->get('fullpath');
        if ($fullpath != '' && $fullpath[mb_strlen($fullpath) - 1] == '/')
        {
            $fullpath = mb_substr($fullpath, 0, -1);
        }
        if (isset($controller[0]))
        {
            if ($controller[0] instanceof FrontPageController)
            {
                if (!($this->page = $this->doctrine->getRepository('FulgurioLightCMSBundle:Page')->findOneBy(array('fullpath' => $fullpath))))
                {
                    throw new NotFoundHttpException();
                }
                if ($this->page->getStatus() === 'draft' && !(
                         $this->securityContext->isGranted('ROLE_ADMIN')
                         && !is_null($event->getRequest()->server->get('HTTP_REFERER'))
                ))
                {
                    throw new NotFoundHttpException();
                }
                //@todo : check access
                $models = $this->kernel->getContainer()->getParameter('fulgurio_light_cms.models');
                if (isset($models[$this->page->getModel()]['front']['controller']))
                {
                    $controller = $this->getController($models[$this->page->getModel()]['front']['controller']);
                    $controller[0]->setContainer($this->kernel->getContainer());
                    $event->setController($controller);
                }
                if (method_exists($controller[0], 'setPage'))
                {
                    $controller[0]->setPage($this->page);
                }
            }
        }
    }
public function onKernelController ( FilterControllerEvent $ event ) { $ controller = $ event -> getController ( ) ; /**
         * $controller passed can be either a class or a Closure. This is not usual in Symfony2 but it may happen.
         * If it is a class, it comes in array format
         */ if ( ! is_array ( $ controller ) ) { return ; } $ fullpath = $ event -> getRequest ( ) -> get ( 'fullpath' ) ; if ( $ fullpath != '' && $ fullpath [ mb_strlen ( $ fullpath ) - 1 ] == '/' ) { $ fullpath = mb_substr ( $ fullpath , 0 , - 1 ) ; } if ( isset ( $ controller [ 0 ] ) ) { if ( $ controller [ 0 ] instanceof FrontPageController ) { if ( ! ( $ this -> page = $ this -> doctrine -> getRepository ( 'FulgurioLightCMSBundle:Page' ) -> findOneBy ( array ( 'fullpath' => $ fullpath ) ) ) ) { throw new NotFoundHttpException ( ) ; } if ( $ this -> page -> getStatus ( ) === 'draft' && ! ( $ this -> securityContext -> isGranted ( 'ROLE_ADMIN' ) && ! is_null ( $ event -> getRequest ( ) -> server -> get ( 'HTTP_REFERER' ) ) ) ) { throw new NotFoundHttpException ( ) ; } //@todo : check access $ models = $ this -> kernel -> getContainer ( ) -> getParameter ( 'fulgurio_light_cms.models' ) ; if ( isset ( $ models [ $ this -> page -> getModel ( ) ] [ 'front' ] [ 'controller' ] ) ) { $ controller = $ this -> getController ( $ models [ $ this -> page -> getModel ( ) ] [ 'front' ] [ 'controller' ] ) ; $ controller [ 0 ] -> setContainer ( $ this -> kernel -> getContainer ( ) ) ; $ event -> setController ( $ controller ) ; } if ( method_exists ( $ controller [ 0 ] , 'setPage' ) ) { $ controller [ 0 ] -> setPage ( $ this -> page ) ; } } } }
OnKernelControler event filter
Try to find the page into database.

@param FilterControllerEvent $event
@throws NotFoundHttpException
@throws AccessDeniedHttpException
@return void|\Fulgurio\LightCMSBundle\EventListener\RedirectResponse
OnKernelControler event filter Try to find the page into database .