WIP: Implement CRUD, improve menu configuration

This commit is contained in:
Björn Fromme
2023-09-27 17:50:42 +02:00
parent c55fd85314
commit c528156959
43 changed files with 2187 additions and 3475 deletions
@@ -0,0 +1,35 @@
<?php
namespace App\Controller\Admin\System\Training;
use App\Entity\Training;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
class DeleteController extends AbstractController
{
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly LoggerInterface $logger
) {
}
#[Route('/admin/system/training/delete/{id}', name: 'app_admin_system_training_delete', methods: ['POST'])]
#[IsGranted('ROLE_ADMIN')]
public function index(Training $training): Response
{
$this->entityManager->remove($training);
$this->entityManager->flush();
$this->addFlash('success', 'Die Fortbildung wurde gelöscht');
$this->logger->info('Delete training', [
'training' => $training->getName(),
]);
return $this->redirectToRoute('app_admin_system_training_index');
}
}