Add collection and new vocab + mess with repository
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\Bibliography;
|
||||
use App\Form\BibliographyType;
|
||||
//use App\Security\Voter\VocabVoter;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
@@ -23,10 +24,18 @@ class BibliographyController extends AbstractController
|
||||
}
|
||||
|
||||
#[Route('/bibliography', name: 'app_bibliography_landing')]
|
||||
public function landing(): Response
|
||||
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,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -38,11 +47,30 @@ class BibliographyController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/bibliography/add', name: 'app_bibliography_add')]
|
||||
/**
|
||||
* @todo Permissions with voter
|
||||
*/
|
||||
#[Route('/bibliography/add', name: 'app_bibliography_create')]
|
||||
public function add(): Response
|
||||
{
|
||||
return $this->render('bibliography/add.html.twig', [
|
||||
$form = $this->createForm(BibliographyType::class);
|
||||
|
||||
return $this->render('bibliography/create.html.twig', [
|
||||
'controller_name' => 'BibliographyController',
|
||||
'form' => $form,
|
||||
]);
|
||||
}
|
||||
/**
|
||||
* @todo Permissions!
|
||||
*/
|
||||
#[Route('/bibliography/delete/{id<\d+>}', name: 'app_bibliography_del')]
|
||||
public function delete(Bibliography $bibliography, EntityManagerInterface $em): Response
|
||||
{
|
||||
$em->remove($bibliography);
|
||||
$em->flush();
|
||||
|
||||
$this->addFlash('notice', 'Term deleted successfully');
|
||||
|
||||
return $this->redirectToRoute('app_bibliography_landing');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user