wip: functionality for new role 'management'
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Administrative\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\Attribute\Route;
|
||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
|
||||
class EditController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly LoggerInterface $logger
|
||||
) {
|
||||
}
|
||||
|
||||
#[Route('/administrative/assignment/edit/{uuid}', name: 'app_administrative_assignment_edit')]
|
||||
#[IsGranted('EDIT', subject: 'assignment')]
|
||||
public function index(Assignment $assignment, Request $request): Response
|
||||
{
|
||||
$form = $this->createForm(
|
||||
AssignmentType::class,
|
||||
$assignment,
|
||||
[
|
||||
'pickup_form_url' => $this->generateUrl('app_administrative_assignment_pickup_form'),
|
||||
]
|
||||
);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash('success', 'Der Einsatz wurde aktualisiert');
|
||||
|
||||
$this->logger->info('Edit assignment', [
|
||||
'assignment_id' => $assignment->getId(),
|
||||
'destination' => (string) $assignment->getDestination(),
|
||||
'job_profile' => $assignment->getJobProfile()->getName(),
|
||||
]);
|
||||
|
||||
return $this->redirectToRoute('app_administrative_assignment_index');
|
||||
}
|
||||
|
||||
return $this->render('administrative/assignment/edit.html.twig', [
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user