46 lines
1.5 KiB
PHP
46 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Controller\Administrative\System\Faq;
|
|
|
|
use App\Entity\Faq;
|
|
use App\Form\FaqType;
|
|
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/system/faq/edit/{id}', name: 'app_administrative_system_faq_edit')]
|
|
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
|
public function index(Faq $faq, Request $request): Response
|
|
{
|
|
$form = $this->createForm(FaqType::class, $faq);
|
|
$form->handleRequest($request);
|
|
|
|
if ($form->isSubmitted() && $form->isValid()) {
|
|
$this->entityManager->flush();
|
|
|
|
$this->addFlash('success', 'Der FAQ-Eintrag wurde aktualisiert');
|
|
$this->logger->info('Edit faq', [
|
|
'faq_id' => $faq->getId(),
|
|
'faq_question' => $faq->getQuestion(),
|
|
]);
|
|
|
|
return $this->redirectToRoute('app_administrative_system_faq_index');
|
|
}
|
|
|
|
return $this->render('administrative/system/faq/edit.html.twig', [
|
|
'form' => $form->createView(),
|
|
]);
|
|
}
|
|
} |