src/Controller/ThemesWebsite/Cvs/Application/DiscussionsController.php line 107

Open in your IDE?
  1. <?php
  2. namespace App\Controller\ThemesWebsite\Cvs\Application;
  3. use App\Entity\Cvs\Candidates;
  4. use App\Entity\Cvs\CandidatesHasExperiences;
  5. use App\Entity\Cvs\CandidatesHasProjects;
  6. use App\Entity\Cvs\CandidatesHasServices;
  7. use App\Entity\Cvs\CandidatesHasSkills;
  8. use App\Services\Core\RequestData;
  9. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
  10. use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
  11. use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
  12. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  13. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  14. use Symfony\Component\HttpFoundation\Request;
  15. use Symfony\Component\HttpFoundation\Response;
  16. use Symfony\Component\Routing\Annotation\Route;
  17. use Symfony\Component\HttpFoundation\Cookie;
  18. use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
  19. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  20. use Doctrine\ORM\EntityManagerInterface;
  21. class DiscussionsController extends AbstractController
  22. {
  23.     private $rd;
  24.     private $em;
  25.     public function __construct(RequestData $rd,
  26.                                 EntityManagerInterface $em
  27.     ) {
  28.         $this->rd $rd;
  29.         $this->em $em;
  30.     }
  31.     /**
  32.      * CV non anonyme
  33.      * @param Request $request
  34.      * @param $slug
  35.      * @return Response
  36.      * @throws \Exception
  37.      */
  38.     public function classic(Request $request$slug): Response
  39.     {
  40.         $candidate $this->em->getRepository(Candidates::class)->findOneBy(['slug' => $slug]);
  41.         if($candidate == null) {
  42.             Throw new \Exception("Aucun candidat");
  43.         }
  44.         if($candidate->getOnlineClassic() !== true) {
  45.             return $this->render('themesWebsite/cvs/application/cv/discussion_classic_offline.html.twig',[
  46.                 'candidate' =>  $candidate
  47.             ]);
  48.         }
  49.         $services =  $this->em->getRepository(CandidatesHasServices::class)->findBy(['candidate' => $candidate->getId()],['title' => 'ASC']);
  50.         $skills =  $this->em->getRepository(CandidatesHasSkills::class)->findBy(['candidate' => $candidate->getId()],['title' => 'ASC']);
  51.         $projects =  $this->em->getRepository(CandidatesHasProjects::class)->findBy(['candidate' => $candidate->getId()],['title' => 'ASC']);
  52.         $experiences =  $this->em->getRepository(CandidatesHasExperiences::class)->findBy(['candidate' => $candidate->getId()],['start' => 'DESC']);
  53.         $views = (int)$candidate->getViews();
  54.         $candidate->setViews($views+1);
  55.         $this->em->persist($candidate);
  56.         $this->em->flush();
  57.         return $this->render('themesWebsite/cvs/application/cv/discussion_classic.html.twig',[
  58.             'candidate' =>  $candidate,
  59.             'services' => $services,
  60.             'skills' => $skills,
  61.             'projects' => $projects,
  62.             'experiences' => $experiences
  63.         ]);
  64.     }
  65.     /**
  66.      * CV anonyme
  67.      * @param Request $request
  68.      * @param $slug
  69.      * @return Response
  70.      * @throws \Exception
  71.      */
  72.     public function anonyme(Request $request$slug): Response
  73.     {
  74.         $candidate $this->em->getRepository(Candidates::class)->findOneBy(['slugAnonyme' => $slug]);
  75.         if($candidate == null) {
  76.             Throw new \Exception("Aucun candidat");
  77.         }
  78.         if($candidate->getOnline() !== true) {
  79.             return $this->render('themesWebsite/cvs/application/cv/discussion_anonyme_offline.html.twig',[
  80.                 'slug' => $slug,
  81.                 'candidate' =>  $candidate
  82.             ]);
  83.         }
  84.         $services =  $this->em->getRepository(CandidatesHasServices::class)->findBy(['candidate' => $candidate->getId()],['title' => 'ASC']);
  85.         $skills =  $this->em->getRepository(CandidatesHasSkills::class)->findBy(['candidate' => $candidate->getId()],['title' => 'ASC']);
  86.         $projects =  $this->em->getRepository(CandidatesHasProjects::class)->findBy(['candidate' => $candidate->getId()],['title' => 'ASC']);
  87.         $experiences =  $this->em->getRepository(CandidatesHasExperiences::class)->findBy(['candidate' => $candidate->getId()],['start' => 'DESC']);
  88.         $views = (int)$candidate->getViewsAnonyme();
  89.         $candidate->setViewsAnonyme($views+1);
  90.         $this->em->persist($candidate);
  91.         $this->em->flush();
  92.         return $this->render('themesWebsite/cvs/application/cv/discussion_anonyme.html.twig',[
  93.             'slug' => $slug,
  94.             'candidate' =>  $candidate,
  95.             'services' => $services,
  96.             'skills' => $skills,
  97.             'projects' => $projects,
  98.             'experiences' => $experiences
  99.         ]);
  100.     }
  101. }