47 lines
1.5 KiB
PHP
47 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Controller\Admin\System\JobProfile;
|
|
|
|
use App\Entity\JobProfile;
|
|
use App\Form\JobProfileType;
|
|
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('/admin/system/job-profile/edit/{id}', name: 'app_admin_system_job_profile_edit')]
|
|
#[IsGranted('ROLE_ADMIN')]
|
|
public function index(JobProfile $jobProfile, Request $request): Response
|
|
{
|
|
$form = $this->createForm(JobProfileType::class, $jobProfile);
|
|
$form->handleRequest($request);
|
|
|
|
if ($form->isSubmitted() && $form->isValid()) {
|
|
$this->entityManager->flush();
|
|
|
|
$this->addFlash('success', 'Das Job-Profil wurde aktualisiert');
|
|
$this->logger->info('Edit Job profile', [
|
|
'job_profile_id' => $jobProfile->getId(),
|
|
'job_profile_name' => $jobProfile->getName(),
|
|
]);
|
|
|
|
return $this->redirectToRoute('app_admin_system_job_profile_index');
|
|
}
|
|
|
|
return $this->render('admin/system/job_profile/edit.html.twig', [
|
|
'form' => $form,
|
|
]);
|
|
}
|
|
}
|