src/Controller/ThemesWebsite/Cvs/Application/CvController.php line 88

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 CvController 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.             return $this->render('themesWebsite/cvs/application/cv/offline.html.twig',[
  43.                 'slug' => $slug,
  44.                 'candidate' =>  $candidate
  45.             ]);
  46.         }
  47.         if($candidate->getOnlineClassic() !== true) {
  48.             return $this->render('themesWebsite/cvs/application/cv/offline.html.twig',[
  49.                 'slug' => $slug,
  50.                 'candidate' =>  $candidate
  51.             ]);
  52.         }
  53.         $services =  $this->em->getRepository(CandidatesHasServices::class)->findBy(['candidate' => $candidate->getId()],['title' => 'ASC']);
  54.         $skills =  $this->em->getRepository(CandidatesHasSkills::class)->findBy(['candidate' => $candidate->getId()],['title' => 'ASC']);
  55.         $projects =  $this->em->getRepository(CandidatesHasProjects::class)->findBy(['candidate' => $candidate->getId()],['title' => 'ASC']);
  56.         $experiences =  $this->em->getRepository(CandidatesHasExperiences::class)->findBy(['candidate' => $candidate->getId()],['start' => 'DESC']);
  57.         $views = (int)$candidate->getViews();
  58.         $candidate->setViews($views+1);
  59.         $this->em->persist($candidate);
  60.         $this->em->flush();
  61.         return $this->render('themesWebsite/cvs/application/cv/classic.html.twig',[
  62.             'slug' => $slug,
  63.             'candidate' =>  $candidate,
  64.             'services' => $services,
  65.             'skills' => $skills,
  66.             'projects' => $projects,
  67.             'experiences' => $experiences
  68.         ]);
  69.     }
  70.     /**
  71.      * CV anonyme
  72.      * @param Request $request
  73.      * @param $slug
  74.      * @return Response
  75.      * @throws \Exception
  76.      */
  77.     public function anonyme(Request $request$slug): Response
  78.     {
  79.         $candidate $this->em->getRepository(Candidates::class)->findOneBy(['slugAnonyme' => $slug]);
  80.         if($candidate == null) {
  81.             return $this->render('themesWebsite/cvs/application/cv/offline.html.twig',[
  82.                 'slug' => $slug,
  83.                 'candidate' =>  $candidate
  84.             ]);
  85.         }
  86.         if($candidate->getOnline() !== true) {
  87.             return $this->render('themesWebsite/cvs/application/cv/offline.html.twig',[
  88.                 'slug' => $slug,
  89.                 'candidate' =>  $candidate
  90.             ]);
  91.         }
  92.         $services =  $this->em->getRepository(CandidatesHasServices::class)->findBy(['candidate' => $candidate->getId()],['title' => 'ASC']);
  93.         $skills =  $this->em->getRepository(CandidatesHasSkills::class)->findBy(['candidate' => $candidate->getId()],['title' => 'ASC']);
  94.         $projects =  $this->em->getRepository(CandidatesHasProjects::class)->findBy(['candidate' => $candidate->getId()],['title' => 'ASC']);
  95.         $experiences =  $this->em->getRepository(CandidatesHasExperiences::class)->findBy(['candidate' => $candidate->getId()],['start' => 'DESC']);
  96.         $views = (int)$candidate->getViewsAnonyme();
  97.         $candidate->setViewsAnonyme($views+1);
  98.         $this->em->persist($candidate);
  99.         $this->em->flush();
  100.         return $this->render('themesWebsite/cvs/application/cv/anonyme.html.twig',[
  101.             'slug' => $slug,
  102.             'candidate' =>  $candidate,
  103.             'services' => $services,
  104.             'skills' => $skills,
  105.             'projects' => $projects,
  106.             'experiences' => $experiences
  107.         ]);
  108.     }
  109. }