<?php
namespace App\Controller;
use App\Entity\Certification;
use App\Entity\CompteRecrutement;
use App\Entity\Diplome;
use App\Entity\Enum\EnglishLevel;
use App\Entity\Enum\FrenchRegion;
use App\Entity\Enum\LegalStatus;
use App\Entity\Enum\SkillLevel;
use App\Entity\Experience;
use App\Entity\Profile;
use App\Entity\Skill;
use App\Entity\User;
use App\Form\ProfileFormType;
use App\Form\IntercontratFormType;
use App\Repository\ProfileRepository;
use App\Repository\UserRepository;
use App\Service\Upload\AvatarUploader;
use App\Service\Upload\PDFUploader;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\EntityManagerInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/tableau-de-bord/profile")
*/
class ProfileController extends AbstractController
{
/**
* @Route("/", name="profile_list", methods={"GET"})
* @IsGranted("ROLE_SOCIETY")
* @param ProfileRepository $profileRepository
* @return Response
*/
public function index(
ProfileRepository $profileRepository,
Request $request,
UserRepository $userRepository
): Response {
$idCompte = $request->query->get("compte");
/* @var User $user */
$user = $this->getUser();
$society = $user->getSociety();
$package = $society->getPackage();
// if (!$society->canViewProfile() || $society->getPackageExpireAt() < new \DateTime()) {
// $this->addFlash('package_error', "Acheter un package supérieur pour voir les intercontrats");
//
// return $this->redirectToRoute('dashboard');
// }
$profils = $profileRepository->findBy(['user' => $user]);
// COMPTE RECRUTEUR
if ($user->getCompteSociety()) {
$profils = $profileRepository->findBy([
'userRecruteur' => $user
]);
} else {
if (!$idCompte) {
$idCompte = "main";
}
// AFFICHER DEPUIS ID RECRUTEUR
if (isset($idCompte) && $idCompte != "all") {
$selectedCompte = $userRepository->findOneBy([
"id" => $idCompte
]);
$profils = $profileRepository->findBy([
'userRecruteur' => $selectedCompte,
'user' => $society->getUser()
]);
}
// AFFICHER SES PRPOPRES OFFRES
if ($idCompte == "main") {
$allProfils = $profileRepository->findBy(['user' => $user]);
$profils = [];
foreach ($allProfils as $profile) {
if (!$profile->getUserRecruteur()) {
$profils[] = $profile;
}
};
}
}
/** @var CompteRecrutement[] $compteRecrutActif */
$compteRecrutActif = [];
if (!empty($society->getCompteRecrutements())) {
foreach ($society->getCompteRecrutements() as $compteRecrutement) {
if ($compteRecrutement->getUserRecruiteur()) {
$compteRecrutActif[] = $compteRecrutement;
}
}
}
return $this->render('profile/index.html.twig', [
'profiles' => $profils,
'package' => $package,
'compteRecrutActif' => $compteRecrutActif,
"selectedCompte" => $idCompte
]);
}
/**
* @Route("/new_before", name="profile_new_before", methods={"GET", "POST"})
*/
function new_before(Request $request, SessionInterface $session, EntityManagerInterface $entityManager, PDFUploader $pdfUploader, AvatarUploader $avatarUploader, ProfileRepository $profileRepository): Response
{
/* @var User $user */
$user = $this->getUser();
$society = $user->getSociety();
$package = $society->getPackage();
// Guard: require an active 'month' or 'year' package to create intercontrats
$allowedPackages = ['month', 'year'];
if (!in_array($package, $allowedPackages, true) || !$society->hasActivePackage()) {
$this->addFlash('package_error', "Il faut avoir un package actif pour pouvoir créer des intercontrats.");
return $this->redirectToRoute('active_package');
}
// if (!$society->canViewProfile() || $society->getPackageExpireAt() < new \DateTime()) {
// $this->addFlash('package_error', "Souscrivez à un package supérieur pour déposer des annonces entre entreprises. ");
//
// return $this->redirectToRoute('dashboard');
// }
if ($user->isCompteTestIsNotActive()) {
$this->addFlash('package_error', "Vous ne pouvez pas créer d'Intercontrat. Votre compte a été désactivé par l'administrateur de la société.");
return $this->redirectToRoute('dashboard');
}
$intercontratUne = abs((int)$user->getSociety()->getIntercontratUne() - (int)$profileRepository->countIntercontratUne($user));
$profile = new Profile();
$profile->setIsIntercontrat(true);
$profile->setUser($user);
$profile->setUrl('');
// COMPTE RECRUTEUR
if ($user->getCompteSociety()) {
$profile->setUserRecruteur($user);
$profile->setUser($user->getSociety()->getUser());
}
if ($request->getMethod() == 'POST') {
// $cvFile = $request->files->get('cv_file');
// if ($cvFile) {
// $uploadDir = $this->getParameter('pdf_directory');
// $newFilename = 'cv-' . uniqid() . '.' . $cvFile->guessExtension();
// $cvFile->move($uploadDir, $newFilename);
// $session->remove('cv_file');
// $session->set('cv_file', $newFilename);
// }
$cvFile = $request->files->get('cv_file');
if ($cvFile) {
$uploadDir = $this->getParameter('pdf_directory');
// Récupérer le nom d'origine du fichier
$originalFilename = pathinfo($cvFile->getClientOriginalName(), PATHINFO_FILENAME);
$extension = $cvFile->guessExtension();
// Créez le nouveau nom de fichier en combinant le nom d'origine avec l'extension
$newFilename = $originalFilename . '.' . $extension;
// Déplacer le fichier téléchargé vers le répertoire de destination
$cvFile->move($uploadDir, $newFilename);
// Gérer la session
$session->remove('cv_file');
$session->set('cv_file', $newFilename);
}
return $this->redirectToRoute('profile_new');
}
return $this->renderForm('profile/new_before.html.twig', [
'profile' => $profile,
'isIntercontrat' => true,
'intercontratUne' => $intercontratUne,
'regionjson' => json_encode(FrenchRegion::REGION_DEPARTEMENT, JSON_UNESCAPED_UNICODE),
'package' => $package
]);
}
/**
* @Route("/new", name="profile_new", methods={"GET", "POST"})
* @param Request $request
* @param EntityManagerInterface $entityManager
* @param PDFUploader $pdfUploader
* @param AvatarUploader $avatarUploader
* @param ProfileRepository $profileRepository
* @return Response
*/
function new(Request $request, SessionInterface $session, EntityManagerInterface $entityManager, PDFUploader $pdfUploader, AvatarUploader $avatarUploader, ProfileRepository $profileRepository): Response
{
$jsonData = $session->get('generated_content');
$cv_path = $session->get('cv_file');
/* @var User $user */
$user = $this->getUser();
$society = $user->getSociety();
$package = $society->getPackage();
if (!$society->canViewProfile() || $society->getPackageExpireAt() < new \DateTime()) {
$this->addFlash('package_error', "Souscrivez à un package supérieur pour déposer des annonces entre entreprises. ");
return $this->redirectToRoute('dashboard');
}
if ($user->isCompteTestIsNotActive()) {
$this->addFlash('package_error', "Vous ne pouvez pas créer d'Intercontrat. Votre compte a été désactivé par l'administrateur de la société.");
return $this->redirectToRoute('dashboard');
}
$intercontratUne = abs((int)$user->getSociety()->getIntercontratUne() - (int)$profileRepository->countIntercontratUne($user));
$profile = new Profile();
$profile->setIsIntercontrat(true);
$profile->setUser($user);
$profile->setUrl('');
$profile->setCdi(false);
// COMPTE RECRUTEUR
if ($user->getCompteSociety()) {
$profile->setUserRecruteur($user);
$profile->setUser($user->getSociety()->getUser());
}
$existing_file = false;
$modalEnreg = false;
if ($jsonData !== null) {
$modalEnreg = true;
// dd($jsonData);
$data = json_decode($jsonData, true);
$existing_file = true;
if (isset($data['Poste'])) $profile->setTitle($data['Poste']);
if (isset($data['nom'])) $profile->setName($data['nom']);
if (isset($data['prenom'])) $profile->setFirstname($data['prenom']);
if (isset($data['tjm']) && $data['tjm'] !== "" && (int)$data['tjm'] !== 0) {
$profile->setCost((int)$data['tjm']);
}
if (isset($data['anglais'])) $profile->setEnglishLevel($data['anglais']);
if (isset($cv_path)) $profile->setCvFile($cv_path);
if (isset($cv_path)) $profile->setCvname($cv_path);
if (isset($data['cp_ville'])) $profile->setLocation($data['cp_ville']);
$skills = [];
if (isset($data['Compétences'])) {
foreach ($data['Compétences'] as $skill => $level) {
// Vérifie que le nom ne contient pas uniquement des chiffres
if (!preg_match('/^\d+$/', $skill)) {
// Convertir le niveau de texte en valeur numérique, ou utiliser 'Débutant' par défaut
$numericLevel = SkillLevel::LIST[$level] ?? SkillLevel::BEGINNER;
$skills[] = [
'name' => $skill,
'level' => $numericLevel
];
}
}
foreach ($skills as $skillData) {
$skill = new Skill();
$skill->setName($skillData['name']);
$skill->setLevel($skillData['level']);
$profile->addSkill($skill);
}
}
if (isset($data['region'])) {
$mobility = $data['region'];
if (is_string($mobility)) {
// Convert string to an array, assuming a comma-separated list
$mobility = explode(',', $mobility);
}
// Set mobility only if it's an array
if (is_array($mobility)) {
$profile->setMobility($mobility);
} else {
$profile->setMobility(null); // Or handle the error appropriately
}
} else {
$profile->setMobility(null);
}
if (isset($data['année_experience'])) $profile->setExperienceNumber($data['année_experience']);
if (isset($data['diplômes'])) {
$diplomeData = $data['diplômes'];
} else {
$diplomeData = null; // Ou définir une valeur par défaut appropriée
}
// dd($diplomeData);
if (!empty($diplomeData)) {
$newDiplome = new Diplome();
if (array_values($diplomeData) !== $diplomeData) {
$newDiplome->setTitle($diplomeData['title'])
->setUniversity($diplomeData['university'] ?? '')
->setLevel($diplomeData['level'] ?? '');
if (isset($diplomeData['obtentionYear']) && is_numeric($diplomeData['obtentionYear'])) {
$obtentionYear = (int)$diplomeData['obtentionYear'];
error_log('Obtention Year: ' . $obtentionYear);
$newDiplome->setObtentionYear($obtentionYear);
}
$profile->addDiplome($newDiplome);
} else {
foreach ($diplomeData as $diplome) {
$newDiplome = new Diplome();
$newDiplome->setTitle($diplome['title'])
->setUniversity($diplome['university'] ?? '')
->setLevel($diplome['level'] ?? '');
if (isset($diplome['obtentionYear']) && is_numeric($diplome['obtentionYear'])) {
$obtentionYear = (int)$diplome['obtentionYear'];
error_log('Obtention Year: ' . $obtentionYear);
$newDiplome->setObtentionYear($obtentionYear);
}
$profile->addDiplome($newDiplome);
}
}
}
// $profile->setPhone(json_decode($jsonData, true)['telephone']);
if (isset($data['experience'])) {
$experienceData = $data['experience'];
} else {
$experienceData = null; // Ou définir une valeur par défaut appropriée
}
if (!empty($experienceData)) {
// Check if it's a single experience or an array of experiences
if (isset($experienceData['title'])) {
// Single experience object, handle it directly
$experienceData = [$experienceData];
}
// Process the JSON data and add experiences to the profile
foreach ($experienceData as $experience) {
$newExperience = new Experience();
$newExperience->setEmployer($experience['employer'] ?? '');
// Set end_at to the last day of the current year if empty
if (empty($experience['end_at'])) {
$currentYear = date('Y');
$endAt = new \DateTime("$currentYear-12-31");
} else {
$endAt = new \DateTime($experience['end_at']);
}
$newExperience->setEndAt($endAt);
if (isset($experience['environment_tech'])) {
if (is_array($experience['environment_tech'])) {
$environmentTech = implode(', ', $experience['environment_tech']);
} else {
$environmentTech = $experience['environment_tech'];
}
} else {
$environmentTech = ''; // Valeur par défaut si 'environment_tech' n'existe pas
}
if (isset($experience['missions'])) {
if (is_array($experience['missions'])) {
// Convertir le tableau en chaîne de caractères avec des sauts de ligne
$missions = array_map(function ($mission) {
if (is_array($mission)) {
// Gérer les tableaux multidimensionnels en les convertissant en une chaîne
return implode(", ", $mission);
} else {
return $mission;
}
}, $experience['missions']);
// Convertir le tableau de missions en une chaîne de caractères
$missions = implode("\n", $missions);
} else {
// Vérifier si 'missions' est déjà une chaîne de caractères
$missions = $experience['missions'];
}
} else {
// Définir une valeur par défaut si 'missions' n'existe pas
$missions = '';
}
$newExperience->setEnvironment($environmentTech)
->setMissions($missions)
->setStartAt(new \DateTime($experience['start_at'] ?? null));
// Assurez-vous que 'title' est toujours une chaîne de caractères
$title = $experience['title'] ?? '';
if (!is_string($title)) {
$title = '';
}
$newExperience->setTitle($title);
$profile->addExperience($newExperience);
}
}
// Vérifier si la clé 'certifications' existe
if (isset($data['certifications'])) {
$certificationData = $data['certifications'];
} else {
$certificationData = null; // Ou définir une valeur par défaut appropriée
}
if (isset($data['anglais'])) {
$anglais = $data['anglais'];
// Mapper des valeurs possibles aux niveaux de la classe
$levelMapping = [
'notions' => EnglishLevel::NOTION,
'technique' => EnglishLevel::TECHNIQUE,
'courant' => EnglishLevel::COURANT,
];
$englishLevel = $levelMapping[strtolower($anglais)] ?? EnglishLevel::NOTION; // Niveau par défaut
// dd($englishLevel);
$profile->setEnglishLevel($englishLevel);
}
if (!empty($certificationData)) {
// Check if it's a single $certificationDat or an array of certificationData
if (isset($certificationData['title'])) {
// Single experience object, handle it directly
$certificationData = [$certificationData];
}
foreach ($certificationData as $certification) {
$newCertification = new Certification();
$newCertification->setTitle($certification['title'] ?? '')
->setEtablissement($certification['etablissement'] ?? '');
// Vérification et conversion de l'année d'obtention
if (isset($certification['obtention_year']) && is_numeric($certification['obtention_year'])) {
$obtentionYear = (int)$certification['obtention_year'];
error_log('Obtention Year: ' . $obtentionYear);
$newCertification->setObtentionYear($obtentionYear);
} else {
// Définir une valeur par défaut appropriée ou gérer l'erreur
error_log('Invalid Obtention Year: ' . (isset($certification['obtention_year']) ? $certification['obtention_year'] : 'not set'));
$newCertification->setObtentionYear(0);
}
$profile->addCertification($newCertification);
}
}
// Vérifier si la clé 'certifications' existe
if (isset($data['présentation'])) {
$presentationData = $data['présentation'];
} else {
$presentationData = null; // Ou définir une valeur par défaut appropriée
}
if (!empty($presentationData)) {
$profile->setAbout($presentationData);
}
if (isset($data['url_Linkedin'])) {
$linkedInData = $data['url_Linkedin'];
} else {
$linkedInData = null; // Ou définir une valeur par défaut appropriée
}
if (!empty($linkedInData)) {
$profile->setLinkedin($linkedInData);
}
// dd($profile);
}
$form = $this->createForm(ProfileFormType::class, $profile, [
'isNew' => true,
'existingFile' => $existing_file
]);
$form->handleRequest($request);
if ($form->isSubmitted()) $modalEnreg = false;
if ($form->isSubmitted() && $form->isValid()) {
$experiences = $profile->getExperiences();
$diplomes = $profile->getDiplomes();
$certifications = $profile->getCertifications();
$skills = $profile->getSkills();
if (!empty($user->getPhoto())) {
$profile->setPhoto($user->getPhoto());
$pdfFile = $form->get('cv_file')->getData();
if (isset($pdfFile) && is_object($pdfFile)) {
$pdfSavedFile = $pdfUploader->upload($pdfFile);
if ($pdfSavedFile) {
$profile->setCvname($pdfSavedFile['name']);
$profile->setCvFile($pdfSavedFile['path']);
}
}
} else {
$this->handleUpload($profile, $form, $pdfUploader, $avatarUploader);
}
$profile->resetContent();
$entityManager->persist($profile);
foreach ($skills as $skill) {
$skill->setProfile($profile);
$entityManager->persist($skill);
}
foreach ($experiences as $experience) {
$experience->setProfile($profile);
$entityManager->persist($experience);
}
foreach ($diplomes as $diplome) {
$diplome->setProfile($profile);
$entityManager->persist($diplome);
}
foreach ($certifications as $certification) {
$certification->setProfile($profile);
$entityManager->persist($certification);
}
$entityManager->flush();
$profile->updateSlug();
$entityManager->persist($profile);
$entityManager->flush();
$session->remove('generated_content');
$session->remove('cv_file');
return $this->redirectToRoute('profile_list', [], Response::HTTP_SEE_OTHER);
}
return $this->renderForm('profile/new.html.twig', [
'profile' => $profile,
'modalEnreg' => $modalEnreg,
'form' => $form,
'isIntercontrat' => true,
'intercontratUne' => $intercontratUne,
'regionjson' => json_encode(FrenchRegion::REGION_DEPARTEMENT, JSON_UNESCAPED_UNICODE),
'package' => $package
]);
}
private function handleUpload(Profile $profile, $form, $pdfUploader, $avatarUploader)
{
$pdfFile = $form->get('cv_file')->getData();
if (isset($pdfFile) && is_object($pdfFile)) {
$pdfSavedFile = $pdfUploader->upload($pdfFile);
if ($pdfSavedFile) {
$profile->setCvname($pdfSavedFile['name']);
$profile->setCvFile($pdfSavedFile['path']);
}
}
$avatarFile = $form->get('photo')->getData();
if (isset($avatarFile)) {
$avatarSavedFile = $avatarUploader->upload($avatarFile);
if ($avatarSavedFile) {
$profile->setPhoto($avatarSavedFile);
}
}
}
/**
* @Route("/cv", name="edit_talent_profile", methods={"GET", "POST"})
*/
public function editTalent(
Request $request,
EntityManagerInterface $entityManager,
PDFUploader $pdfUploader,
AvatarUploader $avatarUploader
): Response {
/* @var User $user */
$user = $this->getUser();
$profile = $user->getUniqueProfile();
$profile->setIsVisible(true);
$cvInitialFileName = $profile->getCvFile();
$isNew = false;
$isCdi = false;
if (!$profile->getId()) {
$isNew = true;
$profile->setUrl($profile->getName());
}
if ($profile->getCdi() === 'Oui') {
$isCdi = true;
}
$profileForm = $request->get('profile_form');
$originalSkills = new ArrayCollection();
$originalExperiences = new ArrayCollection();
$originalDiplomes = new ArrayCollection();
$originalCertifications = new ArrayCollection();
foreach ($profile->getSkills() as $skill) {
$originalSkills->add($skill);
}
foreach ($profile->getExperiences() as $experience) {
$originalExperiences->add($experience);
}
foreach ($profile->getDiplomes() as $diplome) {
$originalDiplomes->add($diplome);
}
foreach ($profile->getCertifications() as $certification) {
$originalCertifications->add($certification);
}
$form = $this->createForm(ProfileFormType::class, $profile, ['isNew' => $isNew, 'isCdi' => $isCdi]);
$form->handleRequest($request);
$cvFileNameValueRequest = $profile->getCvFile();
if ($cvFileNameValueRequest == "" || $cvFileNameValueRequest == null) {
$profile->setCvFile($cvInitialFileName);
}
if ($form->isSubmitted() && $form->isValid()) {
if (!$profile->getId()) {
$entityManager->persist($profile);
}
foreach ($originalSkills as $skill) {
if (false === $profile->getSkills()->contains($skill)) {
$entityManager->remove($skill);
}
}
foreach ($originalExperiences as $experience) {
if (false === $profile->getExperiences()->contains($experience)) {
$entityManager->remove($experience);
}
}
foreach ($originalDiplomes as $diplome) {
if (false === $profile->getDiplomes()->contains($diplome)) {
$entityManager->remove($diplome);
}
}
foreach ($originalCertifications as $certification) {
if (false === $profile->getCertifications()->contains($certification)) {
$entityManager->remove($certification);
}
}
foreach ($profile->getSkills() as $skill) {
$skill->setProfile($profile);
$entityManager->persist($skill);
}
foreach ($profile->getExperiences() as $experience) {
$experience->setProfile($profile);
$entityManager->persist($experience);
}
foreach ($profile->getDiplomes() as $diplome) {
$diplome->setProfile($profile);
$entityManager->persist($diplome);
}
foreach ($profile->getCertifications() as $certification) {
$certification->setProfile($profile);
$entityManager->persist($certification);
}
$this->handleUpload($profile, $form, $pdfUploader, $avatarUploader);
if ($user->isFreelance()) {
$user->setPhoto($profile->getPhoto());
}
if (!empty($profileForm['name'])) {
$user->setLastname($profileForm['name']);
}
if (!empty($profileForm['firstname'])) {
$user->setFirstname($profileForm['firstname']);
}
$entityManager->flush();
$this->addFlash('success', 'Profil mis à jour');
return $this->redirectToRoute('edit_talent_profile', [], Response::HTTP_SEE_OTHER);
}
if ($form->isSubmitted() && !$form->isValid()) {
$this->addFlash('error', 'Un ou plusieurs champs sont incorrect.');
}
return $this->render('profile/edit.html.twig', [
'modalEnreg' => false,
'profile' => $profile,
'form' => $form->createView(),
'isIntercontrat' => false,
'regionjson' => json_encode(FrenchRegion::REGION_DEPARTEMENT, JSON_UNESCAPED_UNICODE),
]);
}
/**
* @Route("/complete_before/{id_user}/{id_data}/{cv_file}/{isIntercontrat}", name="complete_resume_profile_before", methods={"GET", "POST"}, defaults={"id_user"=null,"id_data"=null,"cv_file"=null,"isIntercontrat"=0})
*/
public function completeResumeBefore(
?int $id_user, // L'argument id_user est maintenant facultatif
?string $id_data, // L'argument id_data est maintenant facultatif
?string $cv_file, // L'argument cv_file est maintenant facultatif
?int $isIntercontrat, // L'argument isIntercontrat est maintenant facultatif
Request $request,
EntityManagerInterface $entityManager,
PDFUploader $pdfUploader,
AvatarUploader $avatarUploader,
SessionInterface $session
): Response {
// Si un id_user est fourni, on cherche l'utilisateur correspondant
if ($isIntercontrat === 0) {
if ($id_user !== null) {
$user = $entityManager->getRepository(User::class)->find($id_user);
if ($id_data !== null) {
// récuperer dans $this->getParameter('cv_status_directory') . '/' . $uniqueId . '.json' sur la clé content , donc ['content'];
$data = file_get_contents($this->getParameter('cv_status_directory') . '/' . $id_data . '.json');
$dataArray = json_decode($data, true);
$data = $dataArray['content'] ?? null; // Utiliser une valeur par défaut si 'content' n'existe pas
$data = json_decode($data, true);
$cvFile = $cv_file;
}
if (!$user) {
// Si l'utilisateur n'est pas trouvé, vous pouvez retourner une erreur ou rediriger
throw $this->createNotFoundException('Utilisateur non trouvé');
}
} else {
/* @var User $user */
$user = $this->getUser();
$jsonData = $session->get('generated_content', null);
$data = json_decode($jsonData, true);
$cvFile = $session->get('cv_file');
}
$profile = $user->getUniqueProfile();
} else {
$user = $entityManager->getRepository(User::class)->find($id_user);
// Si isIntercontrat est 1, on crée un nouveau profil
$profile = new Profile();
$profile->setIsIntercontrat(true);
$profile->setUser($user);
$profile->setUrl('');
$profile->setCdi(false);
$cvFile = $cv_file;
$data = file_get_contents($this->getParameter('cv_status_directory') . '/' . $id_data . '.json');
$dataArray = json_decode($data, true);
$data = $dataArray['content'] ?? null; // Utiliser une valeur par défaut si 'content' n'existe pas
$data = json_decode($data, true);
}
// REDIRECT IF COMPLETE
if ($profile->getTitle() && $isIntercontrat === 0) {
return $this->redirectToRoute("complete_first_edit");
}
$profile->setContrats(null);
$profile->setIsVisible(true);
$isNew = false;
if (!$profile->getId() && $isIntercontrat === 0) {
$isNew = true;
$profile->setUrl($profile->getName());
}
$profile->setCvname($cvFile);
$profile->setCvFile($cvFile);
$profile->setCdi('Non');
$profile->setDisponibility('Immédiate');
// dd($data['Compétences']);
if (!empty($data['Compétences'])) {
foreach ($data['Compétences'] as $competence => $levelName) {
$newCompetence = new Skill();
$newCompetence->setName($competence);
// Utilisation de SkillLevel::LIST pour convertir le nom du niveau en entier
$level = is_string($levelName) && isset(SkillLevel::LIST[$levelName])
? SkillLevel::LIST[$levelName]
: SkillLevel::BEGINNER;
// Par défaut 'Débutant' si le niveau n'est pas trouvé
$newCompetence->setLevel($level);
$profile->addSkill($newCompetence);
}
}
(!empty($data['tjm']) && $data['tjm'] != '') ? $profile->setCost((int)$data['tjm']) : $profile->setCost(0);
(!empty($data['region']) && $data['region'] != '' && $data['region'] != 'Pas en France' && !empty($data['cp_ville'])) ? $profile->setMobility([$data['region']]) : $profile->setMobility(["Toute la France"]);
(!empty($data['anglais'])) ? $profile->setEnglishLevel($data['anglais']) : $profile->setEnglishLevel(EnglishLevel::NOTION);
// !empty($data['legalStatus']) ? $profile->setLegalStatus($data['legalStatus']) : $profile->setLegalStatus(LegalStatus::RELFEXION);
!empty($data['legalStatus']) && $data['legalStatus'] !== "En réflexion" ? $profile->setLegalStatus($data['legalStatus']) : $profile->setLegalStatus('');
(!empty($data['année_experience'])) ? $profile->setExperienceNumber($data['année_experience']) : $profile->setExperienceNumber('N/A');
(!empty($data['cp_ville'])) ? $profile->setLocation($data['cp_ville']) : $profile->setLocation('N/A');
(!empty($data['Poste'])) ? $profile->setTitle($data['Poste']) : $profile->setTitle('N/A');
(!empty($data['nom'])) ? $profile->setName($data['nom']) : $profile->setName('Anonyme');
(!empty($data['prenom'])) ? $profile->setFirstname($data['prenom']) : $profile->setFirstname('Anonyme');
if (isset($data['diplômes'])) {
$diplomeData = $data['diplômes'];
} else {
$diplomeData = null; // Ou définir une valeur par défaut appropriée
}
// dd($diplomeData);
if (!empty($diplomeData)) {
$newDiplome = new Diplome();
if (array_values($diplomeData) !== $diplomeData) {
$newDiplome->setTitle($diplomeData['title'])
->setUniversity($diplomeData['university'] ?? '')
->setLevel($diplomeData['level'] ?? '');
if (isset($diplomeData['obtentionYear']) && is_numeric($diplomeData['obtentionYear'])) {
$obtentionYear = (int)$diplomeData['obtentionYear'];
error_log('Obtention Year: ' . $obtentionYear);
$newDiplome->setObtentionYear($obtentionYear);
}
$profile->addDiplome($newDiplome);
} else {
foreach ($diplomeData as $diplome) {
$newDiplome->setTitle($diplome['title'])
->setUniversity($diplome['university'] ?? '')
->setLevel($diplome['level'] ?? '');
if (isset($diplome['obtentionYear']) && is_numeric($diplome['obtentionYear'])) {
$obtentionYear = (int)$diplome['obtentionYear'];
error_log('Obtention Year: ' . $obtentionYear);
$newDiplome->setObtentionYear($obtentionYear);
}
$profile->addDiplome($newDiplome);
}
}
}
$profile->setPhone(empty($data['telephone'] ?? 'N/A') ?? $profile->setPhone('Non spécifié'));
if (isset($data['experience'])) {
$experienceData = $data['experience'];
} else {
$experienceData = null; // Ou définir une valeur par défaut appropriée
}
if (!empty($experienceData)) {
if (isset($experienceData['title'])) {
// Single $experienceDataapeta object, handle it directly
$experienceData = [$experienceData];
}
// Process the JSON data and add experiences to the profile
foreach ($experienceData as $experience) {
$newExperience = new Experience();
$newExperience->setEmployer($experience['employer'] ?? '');
if (!empty($experience['poste_actuel']) && strtolower($experience['poste_actuel'] == "oui")) {
$newExperience->setActualyHere(true);
}
// Set end_at to the last day of the current year if empty
if (empty($experience['end_at']) || (!empty($experience['poste_actuel']) && strtolower($experience['poste_actuel'] == "oui"))) {
$currentYear = date('Y');
// $endAt = new \DateTime("$currentYear-12-31");
$endAt = null;
} else {
try {
$endAt = new \DateTime($experience['end_at']);
} catch (\Exception $e) {
// Handle invalid date format by setting a default date
// $endAt = new \DateTime("$currentYear-12-31");
$endAt = null;
}
}
$newExperience->setEndAt($endAt);
if (isset($experience['environment_tech'])) {
if (is_array($experience['environment_tech'])) {
$environmentTech = implode(', ', $experience['environment_tech']);
} else {
$environmentTech = $experience['environment_tech'];
}
} else {
$environmentTech = ''; // Valeur par défaut si 'environment_tech' n'existe pas
}
if (isset($experience['missions'])) {
if (is_array($experience['missions'])) {
// Convertir le tableau en chaîne de caractères avec des sauts de ligne
$missions = implode("\n", $experience['missions']);
} else {
// Vérifier si 'missions' est déjà une chaîne de caractères
$missions = $experience['missions'];
}
} else {
// Définir une valeur par défaut si 'missions' n'existe pas
$missions = '';
}
try {
$startAt = isset($experience['start_at']) ? new \DateTime($experience['start_at']) : new \DateTime();
} catch (\Exception $e) {
// Utiliser une date par défaut ou gérer l'erreur
$startAt = new \DateTime(); // Date actuelle ou une autre valeur par défaut
}
$newExperience->setEnvironment($environmentTech)
->setMissions($missions)
->setObjectif('')
->setStartAt($startAt);
// Assurez-vous que 'title' est toujours une chaîne de caractères
$title = $experience['title'] ?? '';
if (!is_string($title)) {
$title = '';
}
$newExperience->setTitle($title);
$profile->addExperience($newExperience);
}
}
// Vérifier si la clé 'certifications' existe
if (isset($data['certifications'])) {
$certificationData = $data['certifications'];
} else {
$certificationData = null; // Ou définir une valeur par défaut appropriée
}
if (isset($data['anglais'])) {
$anglais = $data['anglais'];
// Mapper des valeurs possibles aux niveaux de la classe
$levelMapping = [
'notions' => EnglishLevel::NOTION,
'technique' => EnglishLevel::TECHNIQUE,
'courant' => EnglishLevel::COURANT,
];
$englishLevel = $levelMapping[strtolower($anglais)] ?? EnglishLevel::NOTION; // Niveau par défaut
// dd($englishLevel);
$profile->setEnglishLevel($englishLevel);
}
if (!empty($certificationData)) {
foreach ($certificationData as $certification) {
$newCertification = new Certification();
$newCertification->setTitle($certification['title'] ?? '')
->setEtablissement($certification['etablissement'] ?? '');
// Vérification et conversion de l'année d'obtention
if (isset($certification['obtention_year']) && is_numeric($certification['obtention_year'])) {
$obtentionYear = (int)$certification['obtention_year'];
error_log('Obtention Year: ' . $obtentionYear);
$newCertification->setObtentionYear($obtentionYear);
} else {
// Définir une valeur par défaut appropriée ou gérer l'erreur
error_log('Invalid Obtention Year: ' . (isset($certification['obtention_year']) ? $certification['obtention_year'] : 'not set'));
$newCertification->setObtentionYear(0);
}
$profile->addCertification($newCertification);
}
}
// Vérifier si la clé 'certifications' existe
if (isset($data['présentation'])) {
$presentationData = $data['présentation'];
} else {
$presentationData = null; // Ou définir une valeur par défaut appropriée
}
if (!empty($presentationData)) {
$profile->setAbout($presentationData);
}
if (isset($data['url_Linkedin'])) {
$linkedInData = $data['url_Linkedin'];
} else {
$linkedInData = null; // Ou définir une valeur par défaut appropriée
}
if (!empty($linkedInData)) {
$profile->setLinkedin($linkedInData);
}
$profile->setFinished(false);
$profile->setProfileType(0);
// dump($jsonData);
// dd($profile);
$entityManager->flush();
if ($isIntercontrat === 0) {
if (empty($user->getFirstname())) {
$user->setFirstname($profile->getFirstname());
$entityManager->persist($user);
}
if (empty($user->getLastname())) {
$user->setLastname($profile->getName());
$entityManager->persist($user);
}
}
$profile->updateSlug();
// Étape 1 : Enregistrement du profil
$entityManager->persist($profile);
$entityManager->flush(); // À ce stade, $profile->getId() contient l'ID généré
// Étape 2 : Chemin du fichier JSON
$jsonFilePath = $this->getParameter('cv_status_directory') . '/' . $id_data . '.json';
// Étape 3 : Charger le contenu JSON
$data = json_decode(file_get_contents($jsonFilePath), true);
// Étape 4 : Ajouter l’ID du profil
$data['profile_id'] = $profile->getId();
// Étape 5 : Écrire le JSON mis à jour dans le fichier
file_put_contents($jsonFilePath, json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
if ($isIntercontrat === 1) {
return $this->redirectToRoute('profile_list', [], Response::HTTP_SEE_OTHER);
} else {
if ($id_user !== null) {
// suppression du fichier $uniqueId.json
// unlink($this->getParameter('cv_status_directory') . '/' . $id_data . '.json');
return $this->json(['status' => 'success', 'message' => 'Profil créé avec succès'], Response::HTTP_OK);
} else {
return $this->redirectToRoute('complete_first_edit', [], Response::HTTP_SEE_OTHER);
}
}
}
/**
* @Route("/complete_first_edit", name="complete_first_edit", methods={"GET", "POST"})
*/
public function completeResumeFirstEdit(
Request $request,
EntityManagerInterface $entityManager,
PDFUploader $pdfUploader,
AvatarUploader $avatarUploader,
SessionInterface $session
): Response {
/* @var User $user */
$user = $this->getUser();
$profile = $user->getUniqueProfile();
if (!preg_match('/^(https?:\/\/)?([a-z]{2,3}\.)?linkedin\.com\/in\/[a-zA-Z0-9%\-]+\/?$/', $profile->getLinkedin())) {
$profile->setLinkedin(null);
}
// dd($profile);
if ($profile->getLocation() == 'N/A') {
$profile->setLocation('');
}
if ($profile->getFirstname() == 'N/A' || $profile->getFirstname() == 'Anonyme') {
$profile->setFirstname('');
}
if ($profile->getName() == 'N/A' || $profile->getName() == 'Anonyme') {
$profile->setName('');
}
if ($profile->getTitle() == 'N/A') {
$profile->setTitle('');
}
$profile->setMobility([]);
$isNew = true;
$cv_file = $profile->getCvFile();
$originalSkills = new ArrayCollection();
$originalExperiences = new ArrayCollection();
$originalDiplomes = new ArrayCollection();
$originalCertifications = new ArrayCollection();
foreach ($profile->getSkills() as $skill) {
$originalSkills->add($skill);
}
// dd($profile);
// foreach ($profile->getExperiences() as $experience) {
// $originalExperiences->add($experience);
// }
//
// foreach ($profile->getDiplomes() as $diplome) {
// $originalDiplomes->add($diplome);
// }
//
// foreach ($profile->getCertifications() as $certification) {
// $originalCertifications->add($certification);
// }
$form = $this->createForm(ProfileFormType::class, $profile, ['isNew' => $isNew]);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
// $contrats = $form->get('contrats')->getData(); // Cela renvoie un tableau
$profile->setCvFile($cv_file);
// dd($profile);
$session->remove('generated_content');
if (!$profile->getId()) {
$entityManager->persist($profile);
}
foreach ($originalSkills as $skill) {
if (false === $profile->getSkills()->contains($skill)) {
$entityManager->remove($skill);
}
}
// foreach ($originalExperiences as $experience) {
// if (false === $profile->getExperiences()->contains($experience)) {
// $entityManager->remove($experience);
// }
// }
//
// foreach ($originalDiplomes as $diplome) {
// if (false === $profile->getDiplomes()->contains($diplome)) {
// $entityManager->remove($diplome);
// }
// }
//
// foreach ($originalCertifications as $certification) {
// if (false === $profile->getCertifications()->contains($certification)) {
// $entityManager->remove($certification);
// }
// }
foreach ($profile->getSkills() as $skill) {
$skill->setProfile($profile);
$entityManager->persist($skill);
}
// foreach ($profile->getExperiences() as $experience) {
// $experience->setProfile($profile);
// $entityManager->persist($experience);
// }
//
foreach ($profile->getDiplomes() as $diplome) {
if ($diplome->getLevel() == null) {
$diplome->setLevel('');
}
if ($diplome->getUniversity() == null) {
$diplome->setUniversity('');
}
$diplome->setProfile($profile);
$entityManager->persist($diplome);
}
//
// foreach ($profile->getCertifications() as $certification) {
// $certification->setProfile($profile);
// $entityManager->persist($certification);
// }
if (!empty($user->getPhoto())) {
$profile->setPhoto($user->getPhoto());
$pdfFile = $form->get('cv_file')->getData();
if (isset($pdfFile) && is_object($pdfFile)) {
$pdfSavedFile = $pdfUploader->upload($pdfFile);
if ($pdfSavedFile) {
$profile->setCvname($pdfSavedFile['name']);
$profile->setCvFile($pdfSavedFile['path']);
}
}
} else {
$this->handleUpload($profile, $form, $pdfUploader, $avatarUploader);
}
$profile->setFinished(true);
if ($user->isFreelance() && empty($user->getPhoto())) {
$user->setPhoto($profile->getPhoto());
}
if (!empty($profileForm['name'])) {
$user->setLastname($profileForm['name']);
}
if (!empty($profileForm['firstname'])) {
$user->setFirstname($profileForm['firstname']);
}
if (!empty($profileForm['civility'])) {
$user->setCivility($profileForm['civility']);
}
// dd($profile);
$entityManager->flush();
$profile->updateSlug();
$entityManager->persist($profile);
$entityManager->flush();
$this->addFlash('success', 'Profil mis à jour');
return $this->redirectToRoute('edit_talent_profile', [], Response::HTTP_SEE_OTHER);
}
return $this->render('profile/completeResume.html.twig', [
'modalEnreg' => false,
'profile' => $profile,
'form' => $form->createView(),
'isIntercontrat' => false,
'regionjson' => json_encode(FrenchRegion::REGION_DEPARTEMENT, JSON_UNESCAPED_UNICODE),
]);
}
/**
* @Route("/complete", name="complete_resume_profile", methods={"GET", "POST"})
*/
public function completeResume(
Request $request,
EntityManagerInterface $entityManager,
PDFUploader $pdfUploader,
AvatarUploader $avatarUploader,
SessionInterface $session
): Response {
/* @var User $user */
$user = $this->getUser();
$profile = $user->getUniqueProfile();
// REDIRECT IF COMPLETE
if ($profile->getTitle()) {
return $this->redirectToRoute("edit_talent_profile");
}
$profile->setIsVisible(true);
$isNew = false;
if (!$profile->getId()) {
$isNew = true;
$profile->setUrl($profile->getName());
}
$profileForm = $request->get('profile_form');
$originalSkills = new ArrayCollection();
$originalExperiences = new ArrayCollection();
$originalDiplomes = new ArrayCollection();
$originalCertifications = new ArrayCollection();
foreach ($profile->getSkills() as $skill) {
$originalSkills->add($skill);
}
foreach ($profile->getExperiences() as $experience) {
$originalExperiences->add($experience);
}
foreach ($profile->getDiplomes() as $diplome) {
$originalDiplomes->add($diplome);
}
foreach ($profile->getCertifications() as $certification) {
$originalCertifications->add($certification);
}
$form = $this->createForm(ProfileFormType::class, $profile, ['isNew' => $isNew]);
$form->handleRequest($request);
// if ($form->isSubmitted() && $form->isValid()) {
//
//
// // dd($profile);
// $session->remove('generated_content');
//
//
// if (!$profile->getId()) {
// $entityManager->persist($profile);
// }
//
// foreach ($originalSkills as $skill) {
// if (false === $profile->getSkills()->contains($skill)) {
// $entityManager->remove($skill);
// }
// }
//
// foreach ($originalExperiences as $experience) {
// if (false === $profile->getExperiences()->contains($experience)) {
// $entityManager->remove($experience);
// }
// }
//
// foreach ($originalDiplomes as $diplome) {
// if (false === $profile->getDiplomes()->contains($diplome)) {
// $entityManager->remove($diplome);
// }
// }
//
// foreach ($originalCertifications as $certification) {
// if (false === $profile->getCertifications()->contains($certification)) {
// $entityManager->remove($certification);
// }
// }
//
// foreach ($profile->getSkills() as $skill) {
// $skill->setProfile($profile);
// $entityManager->persist($skill);
// }
//
// foreach ($profile->getExperiences() as $experience) {
// $experience->setProfile($profile);
// $entityManager->persist($experience);
// }
//
// foreach ($profile->getDiplomes() as $diplome) {
// $diplome->setProfile($profile);
// $entityManager->persist($diplome);
// }
//
// foreach ($profile->getCertifications() as $certification) {
// $certification->setProfile($profile);
// $entityManager->persist($certification);
// }
//
// if (!empty($user->getPhoto())) {
// $profile->setPhoto($user->getPhoto());
// } else {
// $this->handleUpload($profile, $form, $pdfUploader, $avatarUploader);
// }
//
//
// if ($user->isFreelance() && empty($user->getPhoto())) {
// $user->setPhoto($profile->getPhoto());
// }
//
// if (!empty($profileForm['name'])) {
// $user->setLastname($profileForm['name']);
// }
// if (!empty($profileForm['firstname'])) {
// $user->setFirstname($profileForm['firstname']);
// }
// if (!empty($profileForm['civility'])) {
// $user->setCivility($profileForm['civility']);
// }
//
// $entityManager->flush();
//
// $profile->updateSlug();
// $entityManager->persist($profile);
// $entityManager->flush();
//
// $this->addFlash('success', 'Profil mis à jour');
// return $this->redirectToRoute('edit_talent_profile', [], Response::HTTP_SEE_OTHER);
// }
return $this->render('profile/completeResumeBefore.html.twig', [
'modalEnreg' => false,
'profile' => $profile,
'form' => $form->createView(),
'isIntercontrat' => false,
'regionjson' => json_encode(FrenchRegion::REGION_DEPARTEMENT, JSON_UNESCAPED_UNICODE),
]);
}
/**
* @Route("/{id}", name="profile_show", methods={"GET"})
* @param Profile $profile
* @return Response
*/
public function show(Profile $profile): Response
{
return $this->render('profile/show.html.twig', [
'profile' => $profile,
]);
}
/**
* @Route("/intercontrat_une", name="intercontrat_highlight", methods={"POST"})
*/
public function intercontratHighlight(
Request $request,
ProfileRepository $profileRepository,
EntityManagerInterface $entityManager
) {
/* @var User $user */
$user = $this->getUser();
$profile = $profileRepository->find($request->get('id'));
if ($profile) {
$intercontratUne = abs((int)$user->getSociety()->getIntercontratUne() - (int)$profileRepository->countIntercontratUne($user));
$isHighlight = $request->get('isHighlight');
if ($intercontratUne < 0 && $isHighlight) {
return new JsonResponse(['error' => 'Vous avez dépassez le nombre de contrat en une']);
}
$profile->setIsHighlight($isHighlight);
$entityManager->flush();
}
return new JsonResponse(['success' => true]);
}
/**
* @Route("/{id}/edit/{first}", name="profile_edit", methods={"GET", "POST"}, defaults={"first"=0})
* @param Request $request
* @param Profile $profile
* @param int first
* @param ProfileRepository $profileRepository
* @param EntityManagerInterface $entityManager
* @param PDFUploader $pdfUploader
* @param AvatarUploader $avatarUploader
* @return Response
*/
public function edit(
Request $request,
Profile $profile,
int $first = 0,
ProfileRepository $profileRepository,
EntityManagerInterface $entityManager,
PDFUploader $pdfUploader,
AvatarUploader $avatarUploader
): Response {
/* @var User $user */
$user = $this->getUser();
/**
* ACCESS SOCIETY
*/
if ($profile->getUser() !== $user) {
if ($profile->getUserRecruteur()) {
if ($profile->getUserRecruteur() !== $user) {
return $this->redirectToRoute('app_exception');
}
} else {
return $this->redirectToRoute('app_exception');
}
}
$intercontratUne = abs((int)$user->getSociety()->getIntercontratUne() - (int)$profileRepository->countIntercontratUne($user));
$originalSkills = new ArrayCollection();
$originalExperiences = new ArrayCollection();
$originalDiplomes = new ArrayCollection();
$originalCertifications = new ArrayCollection();
foreach ($profile->getSkills() as $skill) {
$originalSkills->add($skill);
}
foreach ($profile->getExperiences() as $experience) {
$originalExperiences->add($experience);
}
foreach ($profile->getDiplomes() as $diplome) {
$originalDiplomes->add($diplome);
}
foreach ($profile->getCertifications() as $certification) {
$originalCertifications->add($certification);
}
$form = $this->createForm(ProfileFormType::class, $profile, ['isNew' => false]);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$profile->setIsHighlight($request->get('isHighlight', false));
if (!$profile->getId()) {
$entityManager->persist($profile);
}
foreach ($originalSkills as $skill) {
if (false === $profile->getSkills()->contains($skill)) {
$entityManager->remove($skill);
}
}
foreach ($originalExperiences as $experience) {
if (false === $profile->getExperiences()->contains($experience)) {
$entityManager->remove($experience);
}
}
foreach ($originalDiplomes as $diplome) {
if (false === $profile->getDiplomes()->contains($diplome)) {
$entityManager->remove($diplome);
}
}
foreach ($originalCertifications as $certification) {
if (false === $profile->getCertifications()->contains($certification)) {
$entityManager->remove($certification);
}
}
foreach ($profile->getSkills() as $skill) {
$skill->setProfile($profile);
$entityManager->persist($skill);
}
foreach ($profile->getExperiences() as $experience) {
$experience->setProfile($profile);
$entityManager->persist($experience);
}
foreach ($profile->getDiplomes() as $diplome) {
$diplome->setProfile($profile);
$entityManager->persist($diplome);
}
foreach ($profile->getCertifications() as $certification) {
$certification->setProfile($profile);
$entityManager->persist($certification);
}
$this->handleUpload($profile, $form, $pdfUploader, $avatarUploader);
$user = $profile->getUser();
if ($user->isFreelance()) {
$user->setPhoto($profile->getPhoto());
}
$entityManager->flush();
return $this->redirectToRoute('profile_list', [], Response::HTTP_SEE_OTHER);
}
return $this->renderForm('profile/edit.html.twig', [
'modalEnreg' => $first === 1,
'profile' => $profile,
'form' => $form,
'isIntercontrat' => true,
'intercontratUne' => $intercontratUne,
'regionjson' => json_encode(FrenchRegion::REGION_DEPARTEMENT, JSON_UNESCAPED_UNICODE),
]);
}
/**
* @Route("/{id}", name="profile_delete", methods={"POST"})
*/
public function delete(Request $request, Profile $profile, EntityManagerInterface $entityManager): Response
{
/* @var User $user */
$user = $this->getUser();
/**
* ACCESS SOCIETY
*/
if ($profile->getUser() !== $user) {
if ($profile->getUserRecruteur()) {
if ($profile->getUserRecruteur() !== $user) {
return $this->redirectToRoute('app_exception');
}
} else {
return $this->redirectToRoute('app_exception');
}
}
if ($this->isCsrfTokenValid('delete' . $profile->getId(), $request->request->get('_token'))) {
$entityManager->remove($profile);
$entityManager->flush();
}
return $this->redirectToRoute('profile_list', [], Response::HTTP_SEE_OTHER);
}
/**
* @Route("/changer/disponibilité", name="profile_edit_disponibility", methods={"GET"})
* @IsGranted("ROLE_FREELANCE")
*/
public function editDisponibility(
Request $request,
EntityManagerInterface $entityManager
): Response {
$disponibility = $request->query->get("disponibility");
$listDisponibility = [
'Immédiate',
'Sous 1 mois',
'Sous 2 mois',
'Sous 3 mois',
];
if ($disponibility && in_array($disponibility, $listDisponibility)) {
/** @var User $currentUser */
$currentUser = $this->getUser();
$profileUser = $currentUser->getUniqueProfile();
$profileUser->setDisponibility($disponibility);
$entityManager->persist($profileUser);
$entityManager->flush();
}
return $this->redirect($request->headers->get('referer'));
}
}