+ //Render template
+ #return $this->render('@RapsysAir/form/contact.html.twig', ['form' => $form->createView(), 'sent' => $request->query->get('sent', 0)]+$this->context);
+ return $this->render('@RapsysBlog/contact.html.twig', $this->context, $response);
+ }
+
+ /**
+ * The index page
+ *
+ * Display articles
+ *
+ * @param Request $request The request instance
+ * @return Response The rendered view
+ */
+ public function index(Request $request): Response {
+ //With articles
+ if ($count = $this->doctrine->getRepository(Article::class)->findCountAsInt()) {
+ //Negative page or over page
+ if (($page = (int) $request->get('page', 0)) < 0 || $page > $count / $this->limit) {
+ //Throw 404
+ throw $this->createNotFoundException($this->translator->trans('Unable to find articles (page: %page%)', ['%page%' => $page]));
+ }
+
+ //Without articles
+ if (empty($this->context['articles'] = $this->doctrine->getRepository(Article::class)->findAllAsArray($page, $this->limit))) {
+ //Throw 404
+ throw $this->createNotFoundException($this->translator->trans('Unable to find articles'));
+ }
+
+ //With prev link
+ if ($page > 0) {
+ //Set articles older
+ $this->context['head']['prev'] = $this->context['articles_prev'] = $this->generateUrl($request->attributes->get('_route'), ['page' => $page - 1]+$request->attributes->get('_route_params'));
+ }
+
+ //With next link
+ if ($count > ($page + 1) * $this->limit) {
+ //Set articles newer
+ $this->context['head']['next'] = $this->context['articles_next'] = $this->generateUrl($request->attributes->get('_route'), ['page' => $page + 1]+$request->attributes->get('_route_params'));
+ }
+
+ //Set modified
+ $this->modified = max(array_map(function ($v) { return $v['modified']; }, $this->context['articles']));
+ //Without articles
+ } else {
+ //Set empty articles
+ $this->context['articles'] = [];
+
+ //Set empty modified
+ $this->modified = new \DateTime('-1 year');
+ }
+
+ //Create response
+ $response = new Response();
+
+ //With logged user
+ if ($this->checker->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
+ //Set last modified
+ $response->setLastModified(new \DateTime('-1 year'));
+
+ //Set as private
+ $response->setPrivate();
+ //Without logged user
+ } else {
+ //Set etag
+ //XXX: only for public to force revalidation by last modified
+ $response->setEtag(md5(serialize($this->context['articles'])));
+
+ //Set last modified
+ $response->setLastModified($this->modified);
+
+ //Set as public
+ $response->setPublic();
+
+ //Without role and modification
+ if ($response->isNotModified($request)) {
+ //Return 304 response
+ return $response;
+ }
+ }
+
+ //Set keywords
+ $this->context['head']['keywords'] = implode(
+ ', ',
+ //Use closure to extract each unique article keywords sorted
+ (function ($t) {
+ //Return array
+ $r = [];
+
+ //Iterate on articles
+ foreach($t as $a) {
+ //Non empty keywords
+ if (!empty($a['keywords'])) {
+ //Iterate on keywords
+ foreach($a['keywords'] as $k) {
+ //Set keyword
+ $r[$k['title']] = $k['title'];
+ }
+ }
+ }
+
+ //Sort array
+ sort($r);
+
+ //Return array
+ return $r;
+ })($this->context['articles'])
+ );
+
+ //Set title
+ $this->context['title'] = $this->translator->trans('Home');
+
+ //Set description
+ $this->context['description'] = $this->translator->trans('Welcome to raphaël\'s developer diary');
+
+ //Render the view
+ return $this->render('@RapsysBlog/index.html.twig', $this->context, $response);