src/Controller/PageController.php line 28

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\DataProvider\CountryProvider;
  4. use App\DataProvider\RouteProvider;
  5. use App\Entity\Blog;
  6. use App\Entity\Page;
  7. use App\Service\Seo;
  8. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  9. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  10. use App\Helper\BreadcrumbHelper;
  11. class PageController extends Controller
  12. {
  13.     /**
  14.      * @Route("{slug}", name="page_view", requirements={"_locale": "%app_locales%"})
  15.      */
  16.     public function view($_locale$slugBreadcrumbHelper $breadcrumbHelperSeo $seo)
  17.     {
  18.         $page $this->getDoctrine()
  19.             ->getRepository(Page::class)
  20.             ->findOneBy([
  21.                 'is_active' => 1,
  22.                 'slug_'.$_locale => $slug,
  23.             ]);
  24.         if (!$page) {
  25.             throw $this->createNotFoundException('Page not found');
  26.         }
  27.         $page->headertext $page->getHeadertext($_locale);
  28.         $seo->setPage($page);
  29.         $breadcrumbHelper->add($page->getTitle($_locale));
  30.         return $this->render('content/view.html.twig', [
  31.             'breadcrumbs' => $breadcrumbHelper->build(),
  32.             'article' => $page,
  33.         ]);
  34.     }
  35. }