src/Controller/IndexController.php line 54
<?phpnamespace App\Controller;use App\Entity\Web;use App\Form\Front\ContactType;use App\Service\WebService;use App\Service\CategoriesService;use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;use App\Entity\Categorie;use App\Entity\Book;use Doctrine\ORM\EntityManagerInterface;use Symfony\Component\HttpFoundation\JsonResponse;use Symfony\Component\HttpFoundation\Request;use Symfony\Component\HttpFoundation\Response;class IndexController extends AbstractController{/*** @var EntityManagerInterface*/private $em;/*** @var WebService*/private $webFunctions;/*** @var CategoriesService*/private $categoriesFunctions;/*** IndexController constructor.* @param EntityManagerInterface $em* @param WebService $webFunctions*/public function __construct(EntityManagerInterface $em, WebService $webFunctions, CategoriesService $catService){$this->em = $em;$this->webFunctions = $webFunctions;$this->catService = $catService;}/*** Undocumented function** @return Response*/#Route("/", name="indexPage")public function index(){$book = $this->em->getRepository(Book::class)->findBy(array('published' => true), array('createdAt'=>'DESC'));$webElements = $this->webFunctions->reorderWebElements($this->em->getRepository(Web::class)->findBy(array('published' => true), array('position' => 'ASC')));$categories = $this->em->getRepository(Categorie::class)->findAll();$formContact = $this->createForm(ContactType::class)->createView();return $this->render("front/default/index.html.twig", array('categories' => $categories, 'book' => $book, 'web' => $webElements, 'formContact' => $formContact));}/**** @param Request $request* @return Response*/#Route("/web/detail", name="detail_web")public function detailWeb(Request $request): Response{/** Web $web */if(null !== $request->query->get('id')){$id = $request->query->get('id');}else{$id = $request->request->get('id');}$web = $this->em->getRepository(Web::class)->findOneBy(['id' => $id]);return new Response($this->renderView("front/details/detailWeb.html.twig", array('web' => $web)),200,array('Access-Control-Allow-Origin'=> '*'));}/**** @param Request $request* @return Response*/#[Route('/book/detail', name: 'detail_book')]public function detailBook(Request $request): Response{if(null !== $request->query->get('id')){$id = $request->query->get('id');}else{$id = $request->request->get('id');}/** Book $book */$book = $this->em->getRepository(Book::class)->findOneBy(['id' => $id]);return $this->render("front/details/detailBook.html.twig", array('book' => $book));}}