feat: move teamer status editing to admins

addresses #8699yr1eh
This commit is contained in:
Björn Fromme
2025-08-26 14:01:53 +02:00
parent d60119b9fb
commit 86a629d994
4 changed files with 61 additions and 21 deletions
@@ -4,26 +4,66 @@ namespace App\Controller\Admin\Teamer;
use App\Entity\Teamer;
use App\Repository\TrainingRepository;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
class SkillsController extends AbstractController
{
public function __construct(private readonly TrainingRepository $trainingRepository)
{
public function __construct(
private readonly TrainingRepository $trainingRepository,
private readonly EntityManagerInterface $entityManager,
private readonly LoggerInterface $logger,
) {
}
#[Route('/admin/teamer/skills/{uuid}', name: 'app_admin_teamer_skills')]
#[IsGranted('ROLE_ADMIN')]
public function index(Teamer $teamer): Response
public function index(Teamer $teamer, Request $request): Response
{
$trainings = $this->trainingRepository->getList();
$form = $this->createStatusForm($teamer);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->entityManager->flush();
$this->addFlash('success', 'Der Status wurde aktualisiert');
$this->logger->info('Update teamer status to '.$teamer->getStatus(), [
'teamer' => $teamer->getFullName(),
]);
return $this->redirectToRoute('app_admin_teamer_skills', [
'uuid' => $teamer->getUuid(),
]);
}
return $this->render('admin/teamer/skills.html.twig', [
'teamer' => $teamer,
'trainings' => $trainings,
'form' => $form->createView(),
]);
}
private function createStatusForm(Teamer $teamer): FormInterface
{
return $this
->createFormBuilder($teamer)
->add('status', ChoiceType::class, [
'label' => 'Status',
'choices' => [
'Neuteamer' => Teamer::STATUS_NEW,
'Bestandsteamer' => Teamer::STATUS_EXISTING,
],
])
->getForm();
}
}