public function showAction(Request $request)
    {
        /** @var Article $article */
        $article = $this->getDoctrine()->getRepository($this->container->getParameter('vince_cms.class.article'))->find($request->attributes->get('_id'));
        if (!$article || (!$article->isPublished() && !$this->get('security.context')->isGranted('ROLE_ADMIN'))) {
            throw $this->createNotFoundException();
        }

        // Need to inject request as option because of scope limit on listeners
        $options = $this->get('event_dispatcher')->dispatch('vince_cms.event.load', new CmsEvent($article, array('request' => $request)))->getOptions();
        $options = $this->get('event_dispatcher')->dispatch(sprintf('vince_cms.event.load.%s', $article->getSlug()), new CmsEvent($article, $options))->getOptions();
        $options = $this->get('event_dispatcher')->dispatch(sprintf('vince_cms.event.load.template.%s', $article->getTemplate()->getSlug()), new CmsEvent($article, $options))->getOptions();
        if ($response = $this->get('vince_cms.form.handler')->process($request, $options)) {
            return $response;
        }

        return $this->render($article->getTemplate()->getPath(), $options)->setStatusCode($request->isMethod('post') ? 400 : 200);
    }
public function showAction(Request $request)
    {
        /** @var Article $article */
        $article = $this->getDoctrine()->getRepository($this->container->getParameter('vince_cms.class.article'))->find($request->attributes->get('_id'));
        if (!$article || (!$article->isPublished() && !$this->get('security.context')->isGranted('ROLE_ADMIN'))) {
            throw $this->createNotFoundException();
        }

        // Need to inject request as option because of scope limit on listeners
        $options = $this->get('event_dispatcher')->dispatch('vince_cms.event.load', new CmsEvent($article, array('request' => $request)))->getOptions();
        $options = $this->get('event_dispatcher')->dispatch(sprintf('vince_cms.event.load.%s', $article->getSlug()), new CmsEvent($article, $options))->getOptions();
        $options = $this->get('event_dispatcher')->dispatch(sprintf('vince_cms.event.load.template.%s', $article->getTemplate()->getSlug()), new CmsEvent($article, $options))->getOptions();
        if ($response = $this->get('vince_cms.form.handler')->process($request, $options)) {
            return $response;
        }

        return $this->render($article->getTemplate()->getPath(), $options)->setStatusCode($request->isMethod('post') ? 400 : 200);
    }
public function showAction ( Request $ request ) { /** @var Article $article */ $ article = $ this -> getDoctrine ( ) -> getRepository ( $ this -> container -> getParameter ( 'vince_cms.class.article' ) ) -> find ( $ request -> attributes -> get ( '_id' ) ) ; if ( ! $ article || ( ! $ article -> isPublished ( ) && ! $ this -> get ( 'security.context' ) -> isGranted ( 'ROLE_ADMIN' ) ) ) { throw $ this -> createNotFoundException ( ) ; } // Need to inject request as option because of scope limit on listeners $ options = $ this -> get ( 'event_dispatcher' ) -> dispatch ( 'vince_cms.event.load' , new CmsEvent ( $ article , array ( 'request' => $ request ) ) ) -> getOptions ( ) ; $ options = $ this -> get ( 'event_dispatcher' ) -> dispatch ( sprintf ( 'vince_cms.event.load.%s' , $ article -> getSlug ( ) ) , new CmsEvent ( $ article , $ options ) ) -> getOptions ( ) ; $ options = $ this -> get ( 'event_dispatcher' ) -> dispatch ( sprintf ( 'vince_cms.event.load.template.%s' , $ article -> getTemplate ( ) -> getSlug ( ) ) , new CmsEvent ( $ article , $ options ) ) -> getOptions ( ) ; if ( $ response = $ this -> get ( 'vince_cms.form.handler' ) -> process ( $ request , $ options ) ) { return $ response ; } return $ this -> render ( $ article -> getTemplate ( ) -> getPath ( ) , $ options ) -> setStatusCode ( $ request -> isMethod ( 'post' ) ? 400 : 200 ) ; }
Show an article

@author Vincent Chalamon <vincentchalamon@gmail.com>

@param Request $request

@return JsonResponse|RedirectResponse|Response
@throws NotFoundHttpException
@throws \InvalidArgumentException
Show an article