feat: add admin crud for resources and rooms
This commit is contained in:
1 parent
ad5d5acb00
commit
3d67942c62
19 files changed
+1059
-4
No files matched your search
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller\Admin\ResourceGroup;
|
||||
|
||||
use App\Entity\ResourceGroup;
|
||||
use App\Form\Admin\ResourceGroupFormType;
|
||||
use App\Htmx\HxRedirectResponse;
|
||||
use App\Security\Role;
|
||||
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;
|
||||
|
||||
#[IsGranted(Role::ADMIN)]
|
||||
final class EditController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $em,
|
||||
private readonly LoggerInterface $logger,
|
||||
) {
|
||||
}
|
||||
|
||||
#[Route('/admin/resource-groups/{id}/edit', name: 'app_admin_resource_group_edit', methods: ['GET', 'POST'])]
|
||||
public function index(Request $request, ResourceGroup $group): Response
|
||||
{
|
||||
$form = $this->createForm(ResourceGroupFormType::class, $group, [
|
||||
'action' => $this->generateUrl('app_admin_resource_group_edit', ['id' => $group->getId()]),
|
||||
]);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->em->flush();
|
||||
|
||||
$this->logger->info('Admin edited a resource group.', [
|
||||
'admin' => $this->getUser()?->getUserIdentifier(),
|
||||
'group_id' => $group->getId(),
|
||||
'label' => $group->getLabel(),
|
||||
'position' => $group->getPosition(),
|
||||
]);
|
||||
$this->addFlash('success', \sprintf('%s gespeichert.', $group->getLabel()));
|
||||
|
||||
return new HxRedirectResponse($this->generateUrl('app_admin_resource'));
|
||||
}
|
||||
|
||||
return $this->render('admin/_modal_resource_group.html.twig', [
|
||||
'form' => $form,
|
||||
'group' => $group,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user