wip: functionality for new role 'management'

This commit is contained in:
Björn Fromme
2024-02-14 10:42:01 +01:00
parent f80e600310
commit e95310c3a1
50 changed files with 350 additions and 129 deletions
@@ -0,0 +1,46 @@
<?php
namespace App\Controller\Administrative\Assignment;
use App\Entity\Assignment;
use App\Htmx\HxRedirectResponse;
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 DeleteController extends AbstractController
{
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly LoggerInterface $logger
) {
}
#[Route('/administrative/assignment/delete/{uuid}', name: 'app_administrative_assignment_delete')]
#[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(Assignment $assignment, Request $request): Response
{
if (true === $request->isMethod('POST')) {
$assignment->setDeleted();
$this->entityManager->flush();
$this->logger->info('Delete assignment', [
'assignment_id' => $assignment->getId(),
'destination' => (string) $assignment->getDestination(),
'job_profile' => $assignment->getJobProfile()->getName(),
]);
$this->addFlash('success', 'Der Einsatz wurde gelöscht');
return new HxRedirectResponse($this->generateUrl('app_administrative_assignment_index'));
}
return $this->render('administrative/assignment/modal_delete.html.twig', [
'assignment' => $assignment,
]);
}
}