WIP: Implementation of stuff goes on

This commit is contained in:
Björn Fromme
2023-10-05 12:53:17 +02:00
parent 96d6170907
commit 1097b84447
23 changed files with 443 additions and 118 deletions
@@ -0,0 +1,46 @@
<?php
namespace App\Controller\Admin\Assignment;
use App\Entity\Assignment;
use App\Form\AssignmentType;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
class EditController extends AbstractController
{
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly LoggerInterface $logger
) {
}
#[Route('/admin/assignment/edit/{uuid}', name: 'app_admin_assignment_edit')]
#[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(Assignment $assignment, Request $request): Response
{
$form = $this->createForm(AssignmentType::class, $assignment);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->entityManager->flush();
$this->addFlash('success', 'Der Einsatz wurde aktualisiert');
$this->logger->info('Edit assignment', [
'assignment' => $assignment->getUuid(),
]);
return $this->redirectToRoute('app_admin_assignment_index');
}
return $this->render('admin/assignment/edit.html.twig', [
'form' => $form,
]);
}
}