ComptoirController.php 1.52 KB
Newer Older
1 2 3 4
<?php

namespace App\Controller;

5 6
use App\Entity\Comptoir;
use Doctrine\ORM\EntityManagerInterface;
7 8
use Symfony\Component\Routing\Annotation\Route;

9
class ComptoirController extends FrontController
10
{
11
    protected $em;
12 13 14 15 16 17

    public function __construct(EntityManagerInterface $em)
    {
        $this->em = $em;
    }

18 19 20 21 22
    /**
     * @Route("/comptoirs/liste", name="comptoirs_liste")
     */
    public function listeComptoirAction()
    {
23 24 25
        if (!$this->isFrontActivated()) {
            return $this->redirectToRoute('index');
        }
26
        return $this->render('comptoir/liste.html.twig', array(
27
            'comptoirs' => $this->em->getRepository(Comptoir::class)->findBy(array('enabled' => true), array('createdAt' => 'DESC'))
28 29 30 31 32 33 34 35
        ));
    }

    /**
     * @Route("/comptoirs/carte", name="comptoirs_carte")
     */
    public function carteComptoirAction()
    {
36 37 38
        if (!$this->isFrontActivated()) {
            return $this->redirectToRoute('index');
        }
39
        return $this->render('comptoir/carte.html.twig', array(
40
            'comptoirs' => $this->em->getRepository(Comptoir::class)->findBy(array('enabled' => true), array('createdAt' => 'DESC'))
41 42
        ));
    }
43 44 45 46 47 48

    /**
     * @Route("/comptoir/{slug}", name="show_comptoir")
     */
    public function showGroupeAction(Comptoir $comptoir)
    {
49 50 51
        if (!$this->isFrontActivated()) {
            return $this->redirectToRoute('index');
        }
52 53 54 55
        return $this->render('comptoir/show.html.twig', array(
            'comptoir' => $comptoir
        ));
    }
56
}