- //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'));
- }
+ //With not enough articles
+ if (($this->count = $this->doctrine->getRepository(Article::class)->findCountAsInt()) < $this->page * $this->limit) {
+ //Throw 404
+ throw $this->createNotFoundException($this->translator->trans('Unable to find articles'));
+ }