}', name: 'app_bibliography')] public function index(Bibliography $bibliography, EntityManagerInterface $em): Response { $repo = $em->getRepository(Collection::class); $collections = $repo->findAllByBibliography($bibliography->getId()); $repo = $em->getRepository(Collector::class); $collectors = $repo->findAllByBibliography($bibliography->getId()); $bibliography->setCollections($collections); $bibliography->setCollectors($collectors); return $this->render('bibliography/index.html.twig', [ 'controller_name' => 'BibliographyController', 'record' => $bibliography, ]); } #[Route('/bibliography', name: 'app_bibliography_landing')] public function landing(EntityManagerInterface $em): Response { $repo = $em->getRepository(Bibliography::class); $records = $repo->findBy([], ['modifiedAt' => 'DESC']); $count = count($records); $records = array_slice($records, 0, 15); return $this->render('bibliography/landing.html.twig', [ 'controller_name' => 'BibliographyController', 'records' => $records, 'count' => $count, ]); } #[Route('/bibliography/search', name: 'app_bibliography_search')] public function search(): Response { return $this->render('bibliography/search.html.twig', [ 'controller_name' => 'BibliographyController', ]); } /** * @todo Permissions with voter */ #[Route('/bibliography/add', name: 'app_bibliography_create')] public function add(): Response { $form = $this->createForm(BibliographyType::class); return $this->render('bibliography/create.html.twig', [ 'controller_name' => 'BibliographyController', 'form' => $form, ]); } /** * @todo Permissions! Return JSON with 403 when AJAX */ #[Route('/bibliography/delete/{id<\d+>}', name: 'app_bibliography_del')] public function delete(Bibliography $bibliography, EntityManagerInterface $em): Response { try { $this->denyAccessUnlessGranted(RecordVoter::DELETE, $bibliography); } catch (AccessDeniedException) { $this->addFlash('warning', 'You are not authorized to delete this record'); return $this->redirectToRoute('app_home'); } $em->remove($bibliography); $em->flush(); $this->addFlash('notice', 'Record deleted successfully'); return $this->redirectToRoute('app_bibliography_landing'); } }