<?php
namespace App\Controller;
use App\Service\StaticData;
use App\Repository\HobbyAreaRepository;
use App\Repository\HobbySingleRepository;
use App\Repository\PageHeaderRepository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
class HobbyController extends AbstractController
{
public function __construct(EntityManagerInterface $manager, StaticData $statics)
{
$this->manager = $manager;
$this->statics = $statics->getStaticData();
}
/**
* @Route("/{_locale}/activites", name="hobby_index")
*/
public function index(PageHeaderRepository $pageRepo, HobbyAreaRepository $areaRepo, HobbySingleRepository $hobbiesRepo): Response
{
$page = $pageRepo->findOneBy(['page' => 'hobby']);
$area = $areaRepo->findOneBy([]);
$hobbies = $hobbiesRepo->findBy(['display' => true], ['position' => 'ASC']);
return $this->render('hobby/index.html.twig', [
'statics' => $this->statics['data'],
'page' => $page,
'area' => $area,
'hobbies' => $hobbies
]);
}
}