WIP: Implement feedback functionality

This commit is contained in:
Björn Fromme
2023-11-02 18:01:12 +01:00
parent 2689f93683
commit 2599fd69dc
28 changed files with 640 additions and 43 deletions
@@ -0,0 +1,48 @@
<?php
namespace App\Controller\Admin\System\FeedbackSet;
use App\Entity\FeedbackSet;
use App\Form\FeedbackSetType;
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 CreateController extends AbstractController
{
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly LoggerInterface $logger
) {
}
#[Route('/admin/system/feedback-set/create', name: 'app_admin_system_feedback_set_create')]
#[IsGranted('ROLE_ADMIN')]
public function index(Request $request): Response
{
$feedbackSet = new FeedbackSet();
$form = $this->createForm(FeedbackSetType::class, $feedbackSet);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->entityManager->persist($feedbackSet);
$this->entityManager->flush();
$this->addFlash('success', 'Die Feedback-Vorlage wurde angelegt');
$this->logger->info('Create feedback set', [
'feedback_set_id' => $feedbackSet->getId(),
'feedback_set_name' => $feedbackSet->getName(),
]);
return $this->redirectToRoute('app_admin_system_feedback_set_index');
}
return $this->render('admin/system/feedback_set/create.html.twig', [
'form' => $form
]);
}
}
@@ -0,0 +1,36 @@
<?php
namespace App\Controller\Admin\System\FeedbackSet;
use App\Entity\FeedbackSet;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
class DeleteController extends AbstractController
{
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly LoggerInterface $logger
) {
}
#[Route('/admin/system/feedback-set/delete/{id}', name: 'app_admin_system_feedback_set_delete', methods: ['POST'])]
#[IsGranted('ROLE_ADMIN')]
public function index(FeedbackSet $feedbackSet): Response
{
$this->entityManager->remove($feedbackSet);
$this->entityManager->flush();
$this->addFlash('success', 'Die Feedback-Vorlage wurde gelöscht');
$this->logger->info('Delete feedback set', [
'feedback_set_id' => $feedbackSet->getId(),
'feedback_set_name' => $feedbackSet->getName(),
]);
return $this->redirectToRoute('app_admin_system_feedback_set_index');
}
}
@@ -0,0 +1,46 @@
<?php
namespace App\Controller\Admin\System\FeedbackSet;
use App\Entity\FeedbackSet;
use App\Form\FeedbackSetType;
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/system/feedback-set/edit/{id}', name: 'app_admin_system_feedback_set_edit')]
#[IsGranted('ROLE_ADMIN')]
public function index(FeedbackSet $feedbackSet, Request $request): Response
{
$form = $this->createForm(FeedbackSetType::class, $feedbackSet);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->entityManager->flush();
$this->addFlash('success', 'Die Feedback-Vorlage wurde aktualisiert');
$this->logger->info('Edit feedback set', [
'feedback_set_id' => $feedbackSet->getId(),
'feedback_set_name' => $feedbackSet->getName(),
]);
return $this->redirectToRoute('app_admin_system_feedback_set_index');
}
return $this->render('admin/system/feedback_set/edit.html.twig', [
'form' => $form
]);
}
}
@@ -0,0 +1,29 @@
<?php
namespace App\Controller\Admin\System\FeedbackSet;
use App\Repository\FeedbackSetRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
class IndexController extends AbstractController
{
public function __construct(private readonly FeedbackSetRepository $feedbackSetRepository)
{}
#[Route('/admin/system/feedback-set', name: 'app_admin_system_feedback_set_index')]
#[IsGranted('ROLE_ADMIN')]
public function index(): Response
{
$feedbackSets = $this
->feedbackSetRepository
->findAll()
;
return $this->render('admin/system/feedback_set/index.html.twig', [
'feedbackSets' => $feedbackSets,
]);
}
}
@@ -0,0 +1,16 @@
<?php
namespace App\Controller\HouseManager;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class IndexController extends AbstractController
{
#[Route('/house-manager', name: 'app_house_manager_index')]
public function index(): Response
{
return $this->render('');
}
}