src/Controller/NoticeController.php
public function showAction(Request $request)
    {
        $em = $this->getDoctrine()->getManager();
        /* @var $rep NoticeRepository */
        $rep = $em->getRepository('AnimeDbAppBundle:Notice');

        $notice = $rep->getFirstShow();
        // caching
        /* @var $response JsonResponse */
        $response = $this->getCacheTimeKeeper()->getResponse([], -1, new JsonResponse());
        $response->setEtag(md5($notice ? $notice->getId() : 0));
        // response was not modified for this request
        if ($response->isNotModified($request)) {
            return $response;
        }

        // shown notice
        if (!is_null($notice)) {
            $notice->shown();
            $em->persist($notice);
            $em->flush();

            $response->setData([
                'notice' => $notice->getId(),
                'close' => $this->generateUrl('notice_close', ['id' => $notice->getId()]),
                'see_later' => $this->generateUrl('notice_see_later'),
                'content' => $this->renderView('AnimeDbAppBundle:Notice:show.html.twig', [
                    'notice' => $notice,
                    'link_all' => $request->query->getBoolean('all'),
                ]),
            ]);
        }

        return $response;
    }
public function showAction(Request $request)
    {
        $em = $this->getDoctrine()->getManager();
        /* @var $rep NoticeRepository */
        $rep = $em->getRepository('AnimeDbAppBundle:Notice');

        $notice = $rep->getFirstShow();
        // caching
        /* @var $response JsonResponse */
        $response = $this->getCacheTimeKeeper()->getResponse([], -1, new JsonResponse());
        $response->setEtag(md5($notice ? $notice->getId() : 0));
        // response was not modified for this request
        if ($response->isNotModified($request)) {
            return $response;
        }

        // shown notice
        if (!is_null($notice)) {
            $notice->shown();
            $em->persist($notice);
            $em->flush();

            $response->setData([
                'notice' => $notice->getId(),
                'close' => $this->generateUrl('notice_close', ['id' => $notice->getId()]),
                'see_later' => $this->generateUrl('notice_see_later'),
                'content' => $this->renderView('AnimeDbAppBundle:Notice:show.html.twig', [
                    'notice' => $notice,
                    'link_all' => $request->query->getBoolean('all'),
                ]),
            ]);
        }

        return $response;
    }
public function showAction ( Request $ request ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; /* @var $rep NoticeRepository */ $ rep = $ em -> getRepository ( 'AnimeDbAppBundle:Notice' ) ; $ notice = $ rep -> getFirstShow ( ) ; // caching /* @var $response JsonResponse */ $ response = $ this -> getCacheTimeKeeper ( ) -> getResponse ( [ ] , - 1 , new JsonResponse ( ) ) ; $ response -> setEtag ( md5 ( $ notice ? $ notice -> getId ( ) : 0 ) ) ; // response was not modified for this request if ( $ response -> isNotModified ( $ request ) ) { return $ response ; } // shown notice if ( ! is_null ( $ notice ) ) { $ notice -> shown ( ) ; $ em -> persist ( $ notice ) ; $ em -> flush ( ) ; $ response -> setData ( [ 'notice' => $ notice -> getId ( ) , 'close' => $ this -> generateUrl ( 'notice_close' , [ 'id' => $ notice -> getId ( ) ] ) , 'see_later' => $ this -> generateUrl ( 'notice_see_later' ) , 'content' => $ this -> renderView ( 'AnimeDbAppBundle:Notice:show.html.twig' , [ 'notice' => $ notice , 'link_all' => $ request -> query -> getBoolean ( 'all' ) , ] ) , ] ) ; } return $ response ; }
Show last notice.

@param Request $request

@return JsonResponse
Show last notice .