Compare commits
No commits in common. "113171f1958e09739d54c7e19307a1f17f0a2673" and "b201424a2a6e6410c2594e67bbc06026c6103c13" have entirely different histories.
113171f195
...
b201424a2a
@ -5,7 +5,6 @@ namespace App\Controller;
|
||||
use App\Entity\Announcement;
|
||||
use App\Form\AnnouncementType;
|
||||
use App\Repository\AnnouncementRepository;
|
||||
use App\Repository\InternApplicationRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@ -15,13 +14,8 @@ use Symfony\Component\Routing\Attribute\Route;
|
||||
#[Route('/announcement')]
|
||||
final class AnnouncementController extends AbstractController
|
||||
{
|
||||
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly AnnouncementRepository $announcementRepository,
|
||||
){}
|
||||
#[Route('/', name: 'app_announcement_index')]
|
||||
public function list(Request $request,): Response
|
||||
public function list(Request $request, AnnouncementRepository $announcementRepository): Response
|
||||
{
|
||||
$user = $this->getUser();
|
||||
$announcements = [];
|
||||
@ -34,9 +28,9 @@ final class AnnouncementController extends AbstractController
|
||||
$showNonValidated = $request->query->get('show_non_validated');
|
||||
|
||||
if ($showNonValidated) {
|
||||
$announcements = $this->announcementRepository->findBy(['status' => 'notVerified']);
|
||||
$announcements = $announcementRepository->findBy(['status' => 'notVerified']);
|
||||
} else {
|
||||
$announcements = $this->announcementRepository->findAll();
|
||||
$announcements = $announcementRepository->findAll();
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,16 +38,16 @@ final class AnnouncementController extends AbstractController
|
||||
$company = $user->getCompany();
|
||||
|
||||
if ($company) {
|
||||
$announcements = $this->announcementRepository->findBy(['company' => $company]);
|
||||
$announcements = $announcementRepository->findBy(['company' => $company]);
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array('ROLE_INTERN', $user->getRoles())) {
|
||||
$announcements = $this->announcementRepository->findBy(['status' => 'Verified']);
|
||||
$announcements = $announcementRepository->findBy(['status' => 'Verified']);
|
||||
}
|
||||
|
||||
if ($companyName || $location || $category) {
|
||||
$announcements = $this->announcementRepository->searchAnnouncements($companyName, $location, $category);
|
||||
$announcements = $announcementRepository->searchAnnouncements($companyName, $location, $category);
|
||||
}
|
||||
|
||||
$favorites = [];
|
||||
@ -74,7 +68,7 @@ final class AnnouncementController extends AbstractController
|
||||
|
||||
|
||||
#[Route('/new', name: 'app_announcement_new', methods: ['GET', 'POST'])]
|
||||
public function new(Request $request,): Response
|
||||
public function new(Request $request, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
/*$user = $this->getUser();
|
||||
|
||||
@ -95,8 +89,8 @@ final class AnnouncementController extends AbstractController
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$announcement->setCreationDate(new \DateTime());
|
||||
$announcement->setStatus('notVerified');
|
||||
$this->entityManager->persist($announcement);
|
||||
$this->entityManager->flush();
|
||||
$entityManager->persist($announcement);
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('app_announcement_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
@ -116,13 +110,13 @@ final class AnnouncementController extends AbstractController
|
||||
}
|
||||
|
||||
#[Route('/{id}/edit', name: 'app_announcement_edit', methods: ['GET', 'POST'])]
|
||||
public function edit(Request $request, Announcement $announcement,): Response
|
||||
public function edit(Request $request, Announcement $announcement, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$form = $this->createForm(AnnouncementType::class, $announcement);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->entityManager->flush();
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('app_announcement_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
@ -134,23 +128,23 @@ final class AnnouncementController extends AbstractController
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'app_announcement_delete', methods: ['POST'])]
|
||||
public function delete(Request $request, Announcement $announcement,): Response
|
||||
public function delete(Request $request, Announcement $announcement, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
if ($this->isCsrfTokenValid('delete'.$announcement->getId(), $request->getPayload()->getString('_token'))) {
|
||||
$this->entityManager->remove($announcement);
|
||||
$this->entityManager->flush();
|
||||
$entityManager->remove($announcement);
|
||||
$entityManager->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('app_announcement_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
|
||||
#[Route('/{id}/validate', name: 'app_announcement_validate', methods: ['POST'])]
|
||||
public function validate(Request $request, Announcement $announcement,): Response
|
||||
public function validate(Request $request, Announcement $announcement, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
if ($announcement->getStatus() !== 'Verified')
|
||||
{
|
||||
$announcement->setStatus('Verified');
|
||||
$this->entityManager->flush();
|
||||
$entityManager->flush();
|
||||
}
|
||||
return $this->redirectToRoute('app_announcement_show',
|
||||
['id' => $announcement->getId()], Response::HTTP_SEE_OTHER);
|
||||
|
@ -4,9 +4,7 @@ namespace App\Controller;
|
||||
|
||||
use App\Entity\Company;
|
||||
use App\Form\CompanyType;
|
||||
use App\Repository\AnnouncementRepository;
|
||||
use App\Repository\CompanyRepository;
|
||||
use App\Repository\InternApplicationRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@ -17,29 +15,25 @@ use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
#[Route('/company')]
|
||||
final class CompanyController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly CompanyRepository $companyRepository,
|
||||
){}
|
||||
#[Route(name: 'app_company_index', methods: ['GET'])]
|
||||
public function index(): Response
|
||||
public function index(CompanyRepository $companyRepository): Response
|
||||
{
|
||||
return $this->render('company/index.html.twig', [
|
||||
'companies' => $this->companyRepository->findAll(),
|
||||
'companies' => $companyRepository->findAll(),
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/new', name: 'app_company_new', methods: ['GET', 'POST'])]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
public function new(Request $request,): Response
|
||||
public function new(Request $request, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$company = new Company();
|
||||
$form = $this->createForm(CompanyType::class, $company);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->entityManager->persist($company);
|
||||
$this->entityManager->flush();
|
||||
$entityManager->persist($company);
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('app_company_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
@ -60,13 +54,13 @@ final class CompanyController extends AbstractController
|
||||
|
||||
#[Route('/{id}/edit', name: 'app_company_edit', methods: ['GET', 'POST'])]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
public function edit(Request $request, Company $company,): Response
|
||||
public function edit(Request $request, Company $company, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$form = $this->createForm(CompanyType::class, $company);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->entityManager->flush();
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('app_company_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
@ -78,11 +72,11 @@ final class CompanyController extends AbstractController
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'app_company_delete', methods: ['POST'])]
|
||||
public function delete(Request $request, Company $company,): Response
|
||||
public function delete(Request $request, Company $company, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
if ($this->isCsrfTokenValid('delete'.$company->getId(), $request->getPayload()->getString('_token'))) {
|
||||
$this->entityManager->remove($company);
|
||||
$this->entityManager->flush();
|
||||
$entityManager->remove($company);
|
||||
$entityManager->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('app_company_index', [], Response::HTTP_SEE_OTHER);
|
||||
|
@ -5,9 +5,7 @@ namespace App\Controller;
|
||||
use App\Entity\Degree;
|
||||
use App\Entity\InternDegree;
|
||||
use App\Form\DegreeType;
|
||||
use App\Repository\AnnouncementRepository;
|
||||
use App\Repository\DegreeRepository;
|
||||
use App\Repository\InternApplicationRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@ -17,28 +15,24 @@ use Symfony\Component\Routing\Attribute\Route;
|
||||
#[Route('/degree')]
|
||||
final class DegreeController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly DegreeRepository $degreeRepository,
|
||||
){}
|
||||
#[Route(name: 'app_degree_index', methods: ['GET'])]
|
||||
public function index(): Response
|
||||
public function index(DegreeRepository $degreeRepository): Response
|
||||
{
|
||||
return $this->render('degree/index.html.twig', [
|
||||
'degrees' => $this->degreeRepository->findAll(),
|
||||
'degrees' => $degreeRepository->findAll(),
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/new', name: 'app_degree_new', methods: ['GET', 'POST'])]
|
||||
public function new(Request $request,): Response
|
||||
public function new(Request $request, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$degree = new Degree();
|
||||
$form = $this->createForm(DegreeType::class, $degree);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->entityManager->persist($degree);
|
||||
$this->entityManager->flush();
|
||||
$entityManager->persist($degree);
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('app_degree_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
@ -58,13 +52,13 @@ final class DegreeController extends AbstractController
|
||||
}
|
||||
|
||||
#[Route('/{id}/edit', name: 'app_degree_edit', methods: ['GET', 'POST'])]
|
||||
public function edit(Request $request, Degree $degree,): Response
|
||||
public function edit(Request $request, Degree $degree, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$form = $this->createForm(DegreeType::class, $degree);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->entityManager->flush();
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('app_degree_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
@ -76,11 +70,11 @@ final class DegreeController extends AbstractController
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'app_degree_delete', methods: ['POST'])]
|
||||
public function delete(Request $request, Degree $degree,): Response
|
||||
public function delete(Request $request, Degree $degree, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
if ($this->isCsrfTokenValid('delete'.$degree->getId(), $request->getPayload()->getString('_token'))) {
|
||||
$this->entityManager->remove($degree);
|
||||
$this->entityManager->flush();
|
||||
$entityManager->remove($degree);
|
||||
$entityManager->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('app_degree_index', [], Response::HTTP_SEE_OTHER);
|
||||
|
@ -4,9 +4,7 @@ namespace App\Controller;
|
||||
|
||||
use App\Entity\FAQ;
|
||||
use App\Form\FAQType;
|
||||
use App\Repository\AnnouncementRepository;
|
||||
use App\Repository\FAQRepository;
|
||||
use App\Repository\InternApplicationRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@ -17,21 +15,17 @@ use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
#[Route('/faq')]
|
||||
final class FAQController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly FaqRepository $faqRepository,
|
||||
){}
|
||||
#[Route(name: 'app_faq_index', methods: ['GET'])]
|
||||
public function index(): Response
|
||||
public function index(FAQRepository $fAQRepository): Response
|
||||
{
|
||||
return $this->render('faq/index.html.twig', [
|
||||
'faqs' => $this->faqRepository->findAll(),
|
||||
'faqs' => $fAQRepository->findAll(),
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/new', name: 'app_faq_new', methods: ['GET', 'POST'])]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
public function new(Request $request,): Response
|
||||
public function new(Request $request, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$fAQ = new FAQ();
|
||||
$form = $this->createForm(FAQType::class, $fAQ);
|
||||
@ -39,8 +33,8 @@ final class FAQController extends AbstractController
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$fAQ->setUpdateDate(new \DateTime());
|
||||
$this->entityManager->persist($fAQ);
|
||||
$this->entityManager->flush();
|
||||
$entityManager->persist($fAQ);
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('app_faq_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
@ -61,14 +55,14 @@ final class FAQController extends AbstractController
|
||||
|
||||
#[Route('/{id}/edit', name: 'app_faq_edit', methods: ['GET', 'POST'])]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
public function edit(Request $request, FAQ $fAQ,): Response
|
||||
public function edit(Request $request, FAQ $fAQ, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$form = $this->createForm(FAQType::class, $fAQ);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$fAQ->setUpdateDate(new \DateTime());
|
||||
$this->entityManager->flush();
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('app_faq_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
@ -81,11 +75,11 @@ final class FAQController extends AbstractController
|
||||
|
||||
#[Route('/{id}', name: 'app_faq_delete', methods: ['POST'])]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
public function delete(Request $request, FAQ $fAQ,): Response
|
||||
public function delete(Request $request, FAQ $fAQ, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
if ($this->isCsrfTokenValid('delete'.$fAQ->getId(), $request->getPayload()->getString('_token'))) {
|
||||
$this->entityManager->remove($fAQ);
|
||||
$this->entityManager->flush();
|
||||
$entityManager->remove($fAQ);
|
||||
$entityManager->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('app_faq_index', [], Response::HTTP_SEE_OTHER);
|
||||
|
@ -3,9 +3,7 @@
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\UserApp;
|
||||
use App\Repository\AnnouncementRepository;
|
||||
use App\Repository\CompanyRepository;
|
||||
use App\Repository\InternApplicationRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
@ -10,13 +10,7 @@ use App\Entity\InternDegree;
|
||||
use App\Entity\InternSkill;
|
||||
use App\Entity\Skill;
|
||||
use App\Form\InternType;
|
||||
use App\Repository\AnnouncementRepository;
|
||||
use App\Repository\DegreeRepository;
|
||||
use App\Repository\InternApplicationRepository;
|
||||
use App\Repository\InternDegreeRepository;
|
||||
use App\Repository\InternRepository;
|
||||
use App\Repository\InternSkillRepository;
|
||||
use App\Repository\SkillRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@ -26,21 +20,11 @@ use Symfony\Component\Routing\Attribute\Route;
|
||||
#[Route('/intern')]
|
||||
final class InternController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly AnnouncementRepository $announcementRepository,
|
||||
private readonly InternRepository $internRepository,
|
||||
private readonly InternApplicationRepository $internApplicationRepository,
|
||||
private readonly InternDegreeRepository $internDegreeRepository,
|
||||
private readonly InternSkillRepository $internSkillRepository,
|
||||
private readonly DegreeRepository $degreeRepository,
|
||||
private readonly SkillRepository $skillRepository,
|
||||
){}
|
||||
#[Route(name: 'app_intern_index', methods: ['GET'])]
|
||||
public function index(): Response
|
||||
public function index(InternRepository $internRepository): Response
|
||||
{
|
||||
return $this->render('intern/index.html.twig', [
|
||||
'interns' => $this->internRepository->findAll(),
|
||||
'interns' => $internRepository->findAll(),
|
||||
]);
|
||||
}
|
||||
|
||||
@ -53,13 +37,13 @@ final class InternController extends AbstractController
|
||||
}
|
||||
|
||||
#[Route('/{id}/edit', name: 'app_intern_edit', methods: ['GET', 'POST'])]
|
||||
public function edit(Request $request, Intern $intern,): Response
|
||||
public function edit(Request $request, Intern $intern, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$form = $this->createForm(InternType::class, $intern);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->entityManager->flush();
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('app_intern_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
@ -71,18 +55,18 @@ final class InternController extends AbstractController
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'app_intern_delete', methods: ['POST'])]
|
||||
public function delete(Request $request, Intern $intern,): Response
|
||||
public function delete(Request $request, Intern $intern, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
if ($this->isCsrfTokenValid('delete'.$intern->getId(), $request->getPayload()->getString('_token'))) {
|
||||
$this->entityManager->remove($intern);
|
||||
$this->entityManager->flush();
|
||||
$entityManager->remove($intern);
|
||||
$entityManager->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('app_intern_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
|
||||
#[Route('/degrees/add', name:'app_intern_add_degrees', methods:['POST'])]
|
||||
public function addDegrees(Request $request): Response
|
||||
public function addDegrees(Request $request, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$intern = $this->getUser();
|
||||
|
||||
@ -97,14 +81,17 @@ final class InternController extends AbstractController
|
||||
return $this->redirectToRoute('app_degree_index');
|
||||
}
|
||||
|
||||
$degreeRepository = $entityManager->getRepository(Degree::class);
|
||||
$internDegreeRepository = $entityManager->getRepository(InternDegree::class);
|
||||
|
||||
foreach ($selectedDegreeIds as $degreeId) {
|
||||
$degree = $this->degreeRepository->find($degreeId);
|
||||
$degree = $degreeRepository->find($degreeId);
|
||||
|
||||
if (!$degree) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$existingInternDegree = $this->internDegreeRepository->findOneBy([
|
||||
$existingInternDegree = $internDegreeRepository->findOneBy([
|
||||
'intern' => $intern,
|
||||
'degree' => $degree
|
||||
]);
|
||||
@ -115,11 +102,11 @@ final class InternController extends AbstractController
|
||||
$internDegree->setDegree($degree);
|
||||
$internDegree->setGraduationDate(new \DateTime());
|
||||
|
||||
$this->entityManager->persist($internDegree);
|
||||
$entityManager->persist($internDegree);
|
||||
}
|
||||
}
|
||||
|
||||
$this->entityManager->flush();
|
||||
$entityManager->flush();
|
||||
|
||||
$this->addFlash('success', 'Les diplômes ont été ajoutés avec succès.');
|
||||
|
||||
@ -127,17 +114,20 @@ final class InternController extends AbstractController
|
||||
}
|
||||
|
||||
#[Route('/application/send', name:'app_intern_send_application', methods:['POST'])]
|
||||
public function sendApplication(Request $request,): Response
|
||||
public function sendApplication(Request $request, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$intern = $this->getUser();
|
||||
if (!$intern instanceof Intern) {
|
||||
throw $this->createAccessDeniedException("Seuls les stagiaires peuvent envoyer des candidatures.");
|
||||
}
|
||||
|
||||
$announcementId = $request->request->get('announcement_id');
|
||||
$announcement = $this->announcementRepository->find($announcementId);
|
||||
$announcementRepository = $entityManager->getRepository(Announcement::class);
|
||||
$internApplicationRepository = $entityManager->getRepository(InternApplication::class);
|
||||
|
||||
$existingInternApplication = $this->internApplicationRepository->findOneBy([
|
||||
$announcementId = $request->request->get('announcement_id');
|
||||
$announcement = $announcementRepository->find($announcementId);
|
||||
|
||||
$existingInternApplication = $internApplicationRepository->findOneBy([
|
||||
'intern' => $intern,
|
||||
'application' => $announcement
|
||||
]);
|
||||
@ -149,9 +139,9 @@ final class InternController extends AbstractController
|
||||
$internApplication->setApplicationDate(new \DateTime());
|
||||
$internApplication->setStatus("En Attente");
|
||||
|
||||
$this->entityManager->persist($internApplication);
|
||||
$entityManager->persist($internApplication);
|
||||
}
|
||||
$this->entityManager->flush();
|
||||
$entityManager->flush();
|
||||
|
||||
$this->addFlash('success', 'La candidature à bien été envoyée.');
|
||||
|
||||
@ -160,7 +150,7 @@ final class InternController extends AbstractController
|
||||
}
|
||||
|
||||
#[Route('/skills/add', name:'app_intern_add_skills', methods:['POST'])]
|
||||
public function addSkills(Request $request,): Response
|
||||
public function addSkills(Request $request, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$intern = $this->getUser();
|
||||
|
||||
@ -175,12 +165,15 @@ final class InternController extends AbstractController
|
||||
return $this->redirectToRoute('app_skill_index');
|
||||
}
|
||||
|
||||
$skillRepository = $entityManager->getRepository(Skill::class);
|
||||
$internSkillRepository = $entityManager->getRepository(InternSkill::class);
|
||||
|
||||
foreach ($selectedSkillIds as $skillId) {
|
||||
$skill = $this->skillRepository->find($skillId);
|
||||
$skill = $skillRepository->find($skillId);
|
||||
|
||||
if (!$skill) continue;
|
||||
|
||||
$existingInternSkill = $this->internSkillRepository->findOneBy([
|
||||
$existingInternSkill = $internSkillRepository->findOneBy([
|
||||
'intern' => $intern,
|
||||
'skill' => $skill
|
||||
]);
|
||||
@ -190,11 +183,11 @@ final class InternController extends AbstractController
|
||||
$internSkill->setIntern($intern);
|
||||
$internSkill->setSkill($skill);
|
||||
|
||||
$this->entityManager->persist($internSkill);
|
||||
$entityManager->persist($internSkill);
|
||||
}
|
||||
}
|
||||
|
||||
$this->entityManager->flush();
|
||||
$entityManager->flush();
|
||||
|
||||
$this->addFlash('success', 'Les compétences ont été ajoutées avec succès.');
|
||||
|
||||
|
@ -5,9 +5,7 @@ namespace App\Controller;
|
||||
use App\Entity\Announcement;
|
||||
use App\Entity\Intern;
|
||||
use App\Entity\InternFavorite;
|
||||
use App\Repository\AnnouncementRepository;
|
||||
use App\Repository\InternFavoriteRepository;
|
||||
use App\Repository\InternRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
@ -19,69 +17,69 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class InternFavoriteController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly InternFavoriteRepository $internFavoriteRepository,
|
||||
){}
|
||||
#[Route('/favorite/toggle/{id}', name: 'toggle_favorite')]
|
||||
public function toggleFavorite(Announcement $announcement): RedirectResponse {
|
||||
$intern = $this->getUser();
|
||||
public function toggleFavorite(
|
||||
Announcement $announcement,
|
||||
EntityManagerInterface $em,
|
||||
InternFavoriteRepository $repo
|
||||
): RedirectResponse {
|
||||
$intern = $this->getUser()->getIntern();
|
||||
|
||||
$existing = $this->internFavoriteRepository->findOneBy([
|
||||
$existing = $repo->findOneBy([
|
||||
'intern' => $intern,
|
||||
'announcement' => $announcement
|
||||
]);
|
||||
|
||||
if ($existing) {
|
||||
$this->entityManager->remove($existing);
|
||||
$em->remove($existing);
|
||||
} else {
|
||||
$favorite = new InternFavorite();
|
||||
$favorite->setIntern($intern);
|
||||
$favorite->setAnnouncement($announcement);
|
||||
$this->entityManager->persist($favorite);
|
||||
$em->persist($favorite);
|
||||
}
|
||||
|
||||
$this->entityManager->flush();
|
||||
$em->flush();
|
||||
|
||||
return $this->redirectToRoute('app_announcement_index');
|
||||
}
|
||||
|
||||
#[Route('/announcement/{id}/favorite/toggle', name: 'app_favorite_toggle', methods: ['POST'])]
|
||||
public function toggle(Announcement $announcement,Security $security): RedirectResponse
|
||||
public function toggle(Announcement $announcement, EntityManagerInterface $em, Security $security): RedirectResponse
|
||||
{
|
||||
$user = $this->getUser();
|
||||
$user = $security->getUser();
|
||||
|
||||
if (!$user instanceof Intern) {
|
||||
throw new AccessDeniedHttpException('Seuls les stagiaires peuvent ajouter aux favoris.');
|
||||
}
|
||||
|
||||
$favorite = $this->entityManager->getRepository(InternFavorite::class)->findOneBy([
|
||||
$favorite = $em->getRepository(InternFavorite::class)->findOneBy([
|
||||
'intern' => $user,
|
||||
'announcement' => $announcement
|
||||
]);
|
||||
|
||||
if ($favorite) {
|
||||
$this->entityManager->remove($favorite);
|
||||
$em->remove($favorite);
|
||||
} else {
|
||||
$favorite = new InternFavorite();
|
||||
$favorite->setIntern($user);
|
||||
$favorite->setAnnouncement($announcement);
|
||||
$this->entityManager->persist($favorite);
|
||||
$em->persist($favorite);
|
||||
}
|
||||
|
||||
$this->entityManager->flush();
|
||||
$em->flush();
|
||||
|
||||
return new RedirectResponse($_SERVER['HTTP_REFERER'] ?? '/');
|
||||
}
|
||||
|
||||
#[Route('/announcement/{id}', name: 'app_announcement_show')]
|
||||
public function show(Announcement $announcement,): Response
|
||||
public function show(Announcement $announcement, InternFavoriteRepository $internFavoriteRepository): Response
|
||||
{
|
||||
$user = $this->getUser();
|
||||
$isFavorite = false;
|
||||
|
||||
if (in_array('ROLE_INTERN', $user->getRoles())) {
|
||||
$favorite = $this->internFavoriteRepository->findOneBy([
|
||||
$favorite = $internFavoriteRepository->findOneBy([
|
||||
'announcement' => $announcement,
|
||||
'intern' => $user,
|
||||
]);
|
||||
@ -96,12 +94,12 @@ class InternFavoriteController extends AbstractController
|
||||
}
|
||||
|
||||
#[Route('/favorite/add/{id}', name: 'app_favorite_add')]
|
||||
public function addFavorite(Announcement $announcement,): Response
|
||||
public function addFavorite(Announcement $announcement, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$user = $this->getUser();
|
||||
|
||||
// Vérifier si l'intern a déjà ce favori
|
||||
$existingFavorite = $this->entityManager->getRepository(InternFavorite::class)->findOneBy([
|
||||
$existingFavorite = $entityManager->getRepository(InternFavorite::class)->findOneBy([
|
||||
'announcement' => $announcement,
|
||||
'intern' => $user,
|
||||
]);
|
||||
@ -111,26 +109,26 @@ class InternFavoriteController extends AbstractController
|
||||
$favorite->setAnnouncement($announcement);
|
||||
$favorite->setIntern($user);
|
||||
|
||||
$this->entityManager->persist($favorite);
|
||||
$this->entityManager->flush();
|
||||
$entityManager->persist($favorite);
|
||||
$entityManager->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('app_announcement_show', ['id' => $announcement->getId()]);
|
||||
}
|
||||
|
||||
#[Route('/favorite/remove/{id}', name: 'app_favorite_remove')]
|
||||
public function removeFavorite(Announcement $announcement,): Response
|
||||
public function removeFavorite(Announcement $announcement, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$user = $this->getUser();
|
||||
|
||||
$favorite = $this->entityManager->getRepository(InternFavorite::class)->findOneBy([
|
||||
$favorite = $entityManager->getRepository(InternFavorite::class)->findOneBy([
|
||||
'announcement' => $announcement,
|
||||
'intern' => $user,
|
||||
]);
|
||||
|
||||
if ($favorite) {
|
||||
$this->entityManager->remove($favorite);
|
||||
$this->entityManager->flush();
|
||||
$entityManager->remove($favorite);
|
||||
$entityManager->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('app_announcement_show', ['id' => $announcement->getId()]);
|
||||
|
@ -5,33 +5,22 @@ namespace App\Controller;
|
||||
use App\Entity\Message;
|
||||
use App\Entity\UserApp;
|
||||
use App\Form\MessageType;
|
||||
use App\Repository\AnnouncementRepository;
|
||||
use App\Repository\InternSkillRepository;
|
||||
use App\Repository\MessageRepository;
|
||||
use App\Repository\UserRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
#[Route('/message')]
|
||||
final class MessageController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly MessageRepository $messageRepository,
|
||||
private readonly UserRepository $userRepository,
|
||||
){}
|
||||
#[Route(name: 'app_message_index', methods: ['GET'])]
|
||||
public function index(): Response
|
||||
public function index(MessageRepository $messageRepository): Response
|
||||
{
|
||||
$user = $this->getUser();
|
||||
if (!$user instanceof UserApp) {
|
||||
throw new AccessDeniedHttpException("erreur");
|
||||
}
|
||||
$messages = $this->messageRepository->findLatestMessagesByUser($user);
|
||||
$messages = $messageRepository->findLatestMessagesByUser($user);
|
||||
|
||||
return $this->render('message/index.html.twig', [
|
||||
'messages' => $messages,
|
||||
@ -39,12 +28,12 @@ final class MessageController extends AbstractController
|
||||
}
|
||||
|
||||
#[Route('/conversation/{id}', name: 'app_message_conversation', methods: ['GET'])]
|
||||
public function conversation(Message $message,): Response
|
||||
public function conversation(Message $message, MessageRepository $messageRepository): Response
|
||||
{
|
||||
$user = $this->getUser();
|
||||
$otherUser = $message->getSender() === $user ? $message->getReceiver() : $message->getSender();
|
||||
|
||||
$conversation = $this->messageRepository->findByConversation($user, $otherUser);
|
||||
$conversation = $messageRepository->findByConversation($user, $otherUser);
|
||||
|
||||
return $this->render('message/conversation.html.twig', [
|
||||
'conversation' => $conversation,
|
||||
@ -55,12 +44,12 @@ final class MessageController extends AbstractController
|
||||
|
||||
|
||||
#[Route('/new/{receiverId}', name: 'app_message_new', methods: ['GET', 'POST'])]
|
||||
public function new(Request $request, ?int $receiverId = null,): Response
|
||||
public function new(Request $request, EntityManagerInterface $entityManager, ?int $receiverId = null, UserRepository $userRepository): Response
|
||||
{
|
||||
$message = new Message();
|
||||
|
||||
if ($receiverId) {
|
||||
$receiver = $this->userRepository->find($receiverId);
|
||||
$receiver = $userRepository->find($receiverId);
|
||||
if ($receiver) {
|
||||
$message->setReceiver($receiver);
|
||||
}
|
||||
@ -73,8 +62,8 @@ final class MessageController extends AbstractController
|
||||
$message->setSendingDate(new \DateTime());
|
||||
$message->setSender($this->getUser());
|
||||
|
||||
$this->entityManager->persist($message);
|
||||
$this->entityManager->flush();
|
||||
$entityManager->persist($message);
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('app_message_index');
|
||||
}
|
||||
@ -93,14 +82,14 @@ final class MessageController extends AbstractController
|
||||
}
|
||||
|
||||
#[Route('/{id}/edit', name: 'app_message_edit', methods: ['GET', 'POST'])]
|
||||
public function edit(Request $request, Message $message,): Response
|
||||
public function edit(Request $request, Message $message, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$form = $this->createForm(MessageType::class, $message);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$message->setSendingDate(new \DateTime());
|
||||
$this->entityManager->flush();
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('app_message_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
@ -112,11 +101,11 @@ final class MessageController extends AbstractController
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'app_message_delete', methods: ['POST'])]
|
||||
public function delete(Request $request, Message $message,): Response
|
||||
public function delete(Request $request, Message $message, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
if ($this->isCsrfTokenValid('delete'.$message->getId(), $request->getPayload()->getString('_token'))) {
|
||||
$this->entityManager->remove($message);
|
||||
$this->entityManager->flush();
|
||||
$entityManager->remove($message);
|
||||
$entityManager->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('app_message_index', [], Response::HTTP_SEE_OTHER);
|
||||
|
@ -7,7 +7,6 @@ use App\Entity\Intern;
|
||||
use App\Entity\InternApplication;
|
||||
use App\Entity\UserApp;
|
||||
use App\Form\UserAppType;
|
||||
use App\Repository\InternApplicationRepository;
|
||||
use App\Repository\SkillRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
@ -17,12 +16,8 @@ use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
class ProfileController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly InternApplicationRepository $internApplicationRepository,
|
||||
){}
|
||||
#[Route('/profile', name: 'app_profile')]
|
||||
public function profile(): Response
|
||||
public function profile(EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$user = $this->getUser();
|
||||
|
||||
@ -32,8 +27,9 @@ class ProfileController extends AbstractController
|
||||
|
||||
if ($user instanceof Intern)
|
||||
{
|
||||
$internApplicationRepository = $entityManager->getRepository(InternApplication::class);
|
||||
|
||||
$internApplications = $this->internApplicationRepository->findBy([
|
||||
$internApplications = $internApplicationRepository->findBy([
|
||||
'intern' => $user,
|
||||
]);
|
||||
|
||||
@ -50,13 +46,13 @@ class ProfileController extends AbstractController
|
||||
}
|
||||
|
||||
#[Route('profile/{id}/edit', name: 'app_profile_edit', methods: ['GET', 'POST'])]
|
||||
public function edit(Request $request, UserApp $userApp,): Response
|
||||
public function edit(Request $request, UserApp $userApp, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$form = $this->createForm(UserAppType::class, $userApp);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->entityManager->flush();
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('app_profile', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
@ -68,9 +64,9 @@ class ProfileController extends AbstractController
|
||||
}
|
||||
|
||||
#[Route('/profile/visit/{id}', name: 'app_profile_visit')]
|
||||
public function visitProfile(int $id): Response
|
||||
public function visitProfile(EntityManagerInterface $entityManager, int $id): Response
|
||||
{
|
||||
$candidat = $this->entityManager->getRepository(Intern::class)->find($id);
|
||||
$candidat = $entityManager->getRepository(Intern::class)->find($id);
|
||||
|
||||
if (!$candidat) {
|
||||
throw $this->createNotFoundException('Utilisateur non trouvé.');
|
||||
|
@ -6,25 +6,19 @@ use App\Entity\Employee;
|
||||
use App\Entity\Intern;
|
||||
use App\Entity\UserApp;
|
||||
use App\Form\RegistrationFormType;
|
||||
use App\Repository\InternApplicationRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use App\Entity\Company;
|
||||
|
||||
#[Route('/register', name: 'app_register')]
|
||||
class RegistrationController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
){}
|
||||
#[Route('/', name: '_intern')]
|
||||
public function register(Request $request, UserPasswordHasherInterface $userPasswordHasher, Security $security): Response
|
||||
public function register(Request $request, UserPasswordHasherInterface $userPasswordHasher, Security $security, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$user = new Intern();
|
||||
$form = $this->createForm(RegistrationFormType::class, $user);
|
||||
@ -38,52 +32,44 @@ class RegistrationController extends AbstractController
|
||||
// encode the plain password
|
||||
$user->setPassword($userPasswordHasher->hashPassword($user, $plainPassword));
|
||||
|
||||
$this->entityManager->persist($user);
|
||||
$this->entityManager->flush();
|
||||
$entityManager->persist($user);
|
||||
$entityManager->flush();
|
||||
|
||||
// do anything else you need here, like send an email
|
||||
|
||||
return $security->login($user, 'form_login', 'main');
|
||||
}
|
||||
|
||||
return $this->render('registration/register.html.twig', [
|
||||
'registrationForm' => $form,
|
||||
'employee' => False,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/employee', name: '_employee')]
|
||||
public function registerEmployee(Request $request, UserPasswordHasherInterface $userPasswordHasher, Security $security): Response
|
||||
public function registerEmployee(Request $request, UserPasswordHasherInterface $userPasswordHasher, Security $security, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$user = new Employee();
|
||||
$form = $this->createForm(RegistrationFormType::class, $user)
|
||||
->add('company', EntityType::class, [
|
||||
'class' => Company::class,
|
||||
'choice_label' => 'name',
|
||||
'placeholder' => 'Sélectionnez une entreprise',
|
||||
'label' => 'Entreprise',
|
||||
]);
|
||||
$form = $this->createForm(RegistrationFormType::class, $user);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
/** @var string $plainPassword */
|
||||
$plainPassword = $form->get('plainPassword')->getData();
|
||||
|
||||
$company = $form->get('company')->getData();
|
||||
$user->setCompany($company);
|
||||
|
||||
$user->setRoles(['ROLE_EMPLOYEE']);
|
||||
// Encoder le mot de passe
|
||||
// encode the plain password
|
||||
$user->setPassword($userPasswordHasher->hashPassword($user, $plainPassword));
|
||||
|
||||
$this->entityManager->persist($user);
|
||||
$this->entityManager->flush();
|
||||
$entityManager->persist($user);
|
||||
$entityManager->flush();
|
||||
|
||||
// do anything else you need here, like send an email
|
||||
|
||||
return $security->login($user, 'form_login', 'main');
|
||||
}
|
||||
|
||||
return $this->render('registration/register.html.twig', [
|
||||
'registrationForm' => $form,
|
||||
'employee' => True,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Repository\InternApplicationRepository;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
||||
|
@ -4,8 +4,6 @@ namespace App\Controller;
|
||||
|
||||
use App\Entity\Skill;
|
||||
use App\Form\SkillType;
|
||||
use App\Repository\AnnouncementRepository;
|
||||
use App\Repository\InternApplicationRepository;
|
||||
use App\Repository\SkillRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
@ -17,29 +15,25 @@ use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
#[Route('/skill')]
|
||||
final class SkillController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly AnnouncementRepository $skillRepository,
|
||||
){}
|
||||
#[Route(name: 'app_skill_index', methods: ['GET'])]
|
||||
public function index(): Response
|
||||
public function index(SkillRepository $skillRepository): Response
|
||||
{
|
||||
return $this->render('skill/index.html.twig', [
|
||||
'skills' => $this->skillRepository->findAll(),
|
||||
'skills' => $skillRepository->findAll(),
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/new', name: 'app_skill_new', methods: ['GET', 'POST'])]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
public function new(Request $request,): Response
|
||||
public function new(Request $request, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$skill = new Skill();
|
||||
$form = $this->createForm(SkillType::class, $skill);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->entityManager->persist($skill);
|
||||
$this->entityManager->flush();
|
||||
$entityManager->persist($skill);
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('app_skill_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
@ -60,13 +54,13 @@ final class SkillController extends AbstractController
|
||||
|
||||
#[Route('/{id}/edit', name: 'app_skill_edit', methods: ['GET', 'POST'])]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
public function edit(Request $request, Skill $skill,): Response
|
||||
public function edit(Request $request, Skill $skill, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$form = $this->createForm(SkillType::class, $skill);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->entityManager->flush();
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('app_skill_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
@ -79,11 +73,11 @@ final class SkillController extends AbstractController
|
||||
|
||||
#[Route('/{id}', name: 'app_skill_delete', methods: ['POST'])]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
public function delete(Request $request, Skill $skill,): Response
|
||||
public function delete(Request $request, Skill $skill, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
if ($this->isCsrfTokenValid('delete'.$skill->getId(), $request->getPayload()->getString('_token'))) {
|
||||
$this->entityManager->remove($skill);
|
||||
$this->entityManager->flush();
|
||||
$entityManager->remove($skill);
|
||||
$entityManager->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('app_skill_index', [], Response::HTTP_SEE_OTHER);
|
||||
|
@ -4,7 +4,6 @@ namespace App\Controller;
|
||||
|
||||
use App\Entity\UserApp;
|
||||
use App\Form\UserAppType;
|
||||
use App\Repository\AnnouncementRepository;
|
||||
use App\Repository\UserRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
@ -15,15 +14,11 @@ use Symfony\Component\Routing\Attribute\Route;
|
||||
#[Route('/user')]
|
||||
final class UserAppController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly UserRepository $userRepository,
|
||||
){}
|
||||
#[Route(name: 'app_user_index', methods: ['GET'])]
|
||||
public function index(): Response
|
||||
public function index(UserRepository $userRepository): Response
|
||||
{
|
||||
return $this->render('user_app/index.html.twig', [
|
||||
'user_apps' => $this->userRepository->findAll(),
|
||||
'user_apps' => $userRepository->findAll(),
|
||||
]);
|
||||
}
|
||||
|
||||
@ -36,13 +31,13 @@ final class UserAppController extends AbstractController
|
||||
}
|
||||
|
||||
#[Route('/{id}/edit', name: 'app_user_edit', methods: ['GET', 'POST'])]
|
||||
public function edit(Request $request, UserApp $userApp,): Response
|
||||
public function edit(Request $request, UserApp $userApp, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$form = $this->createForm(UserAppType::class, $userApp);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->entityManager->flush();
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('app_user_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
@ -54,11 +49,11 @@ final class UserAppController extends AbstractController
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'app_user_delete', methods: ['POST'])]
|
||||
public function delete(Request $request, UserApp $userApp,): Response
|
||||
public function delete(Request $request, UserApp $userApp, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
if ($this->isCsrfTokenValid('delete'.$userApp->getId(), $request->getPayload()->getString('_token'))) {
|
||||
$this->entityManager->remove($userApp);
|
||||
$this->entityManager->flush();
|
||||
$entityManager->remove($userApp);
|
||||
$entityManager->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('app_user_index', [], Response::HTTP_SEE_OTHER);
|
||||
|
@ -7,7 +7,6 @@ use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
|
||||
#[ORM\Entity(repositoryClass: CompanyRepository::class)]
|
||||
class Company
|
||||
{
|
||||
|
@ -7,7 +7,6 @@ use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use App\Entity\Company;
|
||||
|
||||
#[ORM\Entity(repositoryClass: InternRepository::class)]
|
||||
class Intern extends UserApp
|
||||
@ -192,22 +191,6 @@ class Intern extends UserApp
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
#[ORM\ManyToOne(targetEntity: Company::class)]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?Company $company = null;
|
||||
|
||||
// Getter et setter pour la société
|
||||
public function getCompany(): ?Company
|
||||
{
|
||||
return $this->company;
|
||||
}
|
||||
|
||||
public function setCompany(?Company $company): self
|
||||
{
|
||||
$this->company = $company;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@ -186,7 +186,6 @@ class UserApp implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,19 +15,12 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Validator\Constraints\IsTrue;
|
||||
use Symfony\Component\Validator\Constraints\Length;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use App\Entity\Company;
|
||||
use App\Entity\Intern;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
|
||||
|
||||
class RegistrationFormType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
|
||||
->add('nickname', TextType::class, [
|
||||
'label' => 'Utilisateur : ',
|
||||
])
|
||||
@ -52,7 +45,10 @@ class RegistrationFormType extends AbstractType
|
||||
new NotBlank(),
|
||||
]
|
||||
])
|
||||
//
|
||||
->add('plainPassword', PasswordType::class, [
|
||||
// instead of being set onto the object directly,
|
||||
// this is read and encoded in the controller
|
||||
'mapped' => false,
|
||||
'attr' => ['autocomplete' => 'new-password'],
|
||||
'constraints' => [
|
||||
@ -62,10 +58,12 @@ class RegistrationFormType extends AbstractType
|
||||
new Length([
|
||||
'min' => 6,
|
||||
'minMessage' => 'Votre mot de passe doit avoir au moins {{ limit }} caractères',
|
||||
// max length allowed by Symfony for security reasons
|
||||
'max' => 4096,
|
||||
]),
|
||||
],
|
||||
]);
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
|
@ -36,15 +36,6 @@
|
||||
{{ form_errors(registrationForm.mail) }}
|
||||
</div>
|
||||
|
||||
{% if employee %}
|
||||
<div class="mb-4">
|
||||
{{ form_label(registrationForm.company, 'Sélectionnez une entreprise', {'label_attr': {'class': 'block text-gray-700 mb-2'}}) }}
|
||||
{{ form_widget(registrationForm.company, {'attr': {'class': 'w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-teal-500'}}) }}
|
||||
{{ form_errors(registrationForm.company) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- Mot de passe -->
|
||||
<div class="mb-4">
|
||||
{{ form_label(registrationForm.plainPassword, 'Mot de passe', {'label_attr': {'class': 'block text-gray-700 mb-2'}}) }}
|
||||
{{ form_widget(registrationForm.plainPassword, {'attr': {'class': 'w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-teal-500'}}) }}
|
||||
|
Loading…
x
Reference in New Issue
Block a user