WIP: Implement admin CRUD

This commit is contained in:
Björn Fromme
2023-09-26 17:44:01 +02:00
parent 3e0353c79b
commit c55fd85314
63 changed files with 1367 additions and 532 deletions
@@ -0,0 +1,47 @@
<?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\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/job-profile/create', name: 'app_admin_system_job_profile_create')]
#[IsGranted('ROLE_ADMIN')]
public function index(Request $request): Response
{
$jobProfile = new JobProfile();
$form = $this->createForm(JobProfileType::class, $jobProfile);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->entityManager->persist($jobProfile);
$this->entityManager->flush();
$this->addFlash('success', 'Das Job-Profil wurde angelegt');
$this->logger->info('Create Job profile', [
'job_profile' => $jobProfile->getName(),
]);
return $this->redirectToRoute('app_admin_system_job_profile_index');
}
return $this->render('admin/system/job_profile/create.html.twig', [
'form' => $form
]);
}
}
@@ -0,0 +1,29 @@
<?php
namespace App\Controller\Admin\System\JobProfile;
use App\Repository\JobProfileRepository;
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 JobProfileRepository $jobProfileRepository)
{}
#[Route('/admin/system/job-profile', name: 'app_admin_system_job_profile_index')]
#[IsGranted('ROLE_ADMIN')]
public function index(): Response
{
$jobProfiles = $this
->jobProfileRepository
->getList()
;
return $this->render('admin/system/job_profile/index.html.twig', [
'jobProfiles' => $jobProfiles,
]);
}
}