src/Entity/Profil/Profil.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Profil;
  3. use App\Entity\EntityIdentifier;
  4. use App\Entity\JobConfiguration\Job;
  5. use App\Entity\Quiz\RiasecBigFive\RBQuiz;
  6. use App\Entity\Quiz\RiasecQuizResponse;
  7. use App\Entity\UserRiasecProfile;
  8. use App\Repository\Profil\ProfilRepository;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use Knp\DoctrineBehaviors\Model as ORMBehaviors;
  13. use Symfony\Component\Serializer\Annotation\Groups;
  14. /**
  15.  * @ORM\Entity(repositoryClass=ProfilRepository::class)
  16.  * @ORM\HasLifecycleCallbacks()
  17.  */
  18. class Profil
  19. {
  20.     
  21.     use ORMBehaviors\Translatable\Translatable;
  22.     
  23.     use EntityIdentifier;
  24.     
  25.     /**
  26.      * @ORM\Id
  27.      * @ORM\GeneratedValue
  28.      * @ORM\Column(type="integer")
  29.      */
  30.     private $id;
  31.     /**
  32.      * @ORM\Column(type="string", length=255, nullable=true)
  33.      */
  34.     private $color;
  35.     
  36.     /**
  37.      * @ORM\OneToMany(targetEntity=ProfilTranslation::class, mappedBy="translatable", cascade={"persist"})
  38.      */
  39.     protected $newTranslations;
  40.     /**
  41.      * @ORM\OneToMany(targetEntity=RiasecQuizResponse::class, mappedBy="profile")
  42.      */
  43.     private $riasecQuizResponses;
  44.     /**
  45.      * @ORM\Column(type="string", length=255, nullable=true)
  46.      * @Groups({"badge_cv"})
  47.      */
  48.     private $icon;
  49.     /**
  50.      * @ORM\OneToMany(targetEntity=Job::class, mappedBy="majorProfile")
  51.      */
  52.     private $jobs;
  53.     /**
  54.      * @ORM\OneToMany(targetEntity=Job::class, mappedBy="minorProfile")
  55.      */
  56.     private $jobMinors;
  57.     /**
  58.      * @ORM\OneToMany(targetEntity=Job::class, mappedBy="fair")
  59.      */
  60.     private $jobFairs;
  61.     /**
  62.      * @ORM\OneToMany(targetEntity=TwiceProfile::class, mappedBy="profileA")
  63.      */
  64.     private $twiceProfilesA;
  65.     /**
  66.      * @ORM\OneToMany(targetEntity=TwiceProfile::class, mappedBy="profileB")
  67.      */
  68.     private $twiceProfilesB;
  69.     /**
  70.      * @ORM\OneToMany(targetEntity=ProfilPositiveDescription::class, mappedBy="profil")
  71.      */
  72.     private $profilPositiveDescriptions;
  73.     /**
  74.      * @ORM\OneToMany(targetEntity=ProfilNegativeDescription::class, mappedBy="profil")
  75.      */
  76.     private $profilNegativeDescriptions;
  77.     /**
  78.      * @ORM\OneToMany(targetEntity=RBQuiz::class, mappedBy="riasecProfile")
  79.      */
  80.     private $rBQuizzes;
  81.     /**
  82.      * @ORM\OneToMany(targetEntity=UserRiasecProfile::class, mappedBy="riasecProfile")
  83.      */
  84.     private $userRiasecProfiles;
  85.     /**
  86.      * @ORM\Column(type="string", length=10, nullable=true)
  87.      */
  88.     private $mainletter;
  89.     public function __construct()
  90.     {
  91.         $this->riasecQuizResponses = new ArrayCollection();
  92.         $this->jobs = new ArrayCollection();
  93.         $this->jobMinors = new ArrayCollection();
  94.         $this->jobFairs = new ArrayCollection();
  95.         $this->twiceProfilesA = new ArrayCollection();
  96.         $this->twiceProfilesB = new ArrayCollection();
  97.         $this->profilPositiveDescriptions = new ArrayCollection();
  98.         $this->profilNegativeDescriptions = new ArrayCollection();
  99.         $this->rBQuizzes = new ArrayCollection();
  100.         $this->userRiasecProfiles = new ArrayCollection();
  101.     }
  102.     
  103.     /**
  104.      * @ORM\PostLoad()
  105.      */
  106.     public function init() {
  107.                                                                                    $this->mergeNewTranslations();
  108.                                                                                    $this->currentLocale = \Locale::getDefault();
  109.                                                                                }
  110.     public function getId(): ?int
  111.     {
  112.         return $this->id;
  113.     }
  114.     public function getColor(): ?string
  115.     {
  116.         return $this->color;
  117.     }
  118.     public function setColor(?string $color): self
  119.     {
  120.         $this->color $color;
  121.         return $this;
  122.     }
  123.     
  124.     public function __call($name$arguments) {
  125.                                                                                    $reflect = new \ReflectionClass(ProfilTranslation::class);
  126.                                                                                    $privateProperties $reflect->getProperties(\ReflectionProperty::IS_PRIVATE);
  127.                                                                                    
  128.                                                                                    foreach ($privateProperties as $property) {
  129.                                                                                        if($property->getName() == $name) {
  130.                                                                                            return $this->translate()->{"get" ucfirst($name)}();
  131.                                                                                        }
  132.                                                                                    }
  133.                                                                                    
  134.                                                                                    return "";
  135.                                                                                }
  136.     /**
  137.      * @return Collection<int, RiasecQuizResponse>
  138.      */
  139.     public function getRiasecQuizResponses(): Collection
  140.     {
  141.         return $this->riasecQuizResponses;
  142.     }
  143.     public function addRiasecQuizResponse(RiasecQuizResponse $riasecQuizResponse): self
  144.     {
  145.         if (!$this->riasecQuizResponses->contains($riasecQuizResponse)) {
  146.             $this->riasecQuizResponses[] = $riasecQuizResponse;
  147.             $riasecQuizResponse->setProfile($this);
  148.         }
  149.         return $this;
  150.     }
  151.     public function removeRiasecQuizResponse(RiasecQuizResponse $riasecQuizResponse): self
  152.     {
  153.         if ($this->riasecQuizResponses->removeElement($riasecQuizResponse)) {
  154.             // set the owning side to null (unless already changed)
  155.             if ($riasecQuizResponse->getProfile() === $this) {
  156.                 $riasecQuizResponse->setProfile(null);
  157.             }
  158.         }
  159.         return $this;
  160.     }
  161.     public function getIcon(): ?string
  162.     {
  163.         return $this->icon;
  164.     }
  165.     public function setIcon(?string $icon): self
  166.     {
  167.         $this->icon $icon;
  168.         return $this;
  169.     }
  170.     /**
  171.      * @return Collection<int, Job>
  172.      */
  173.     public function getJobs(): Collection
  174.     {
  175.         return $this->jobs;
  176.     }
  177.     public function addJob(Job $job): self
  178.     {
  179.         if (!$this->jobs->contains($job)) {
  180.             $this->jobs[] = $job;
  181.             $job->setMajorProfile($this);
  182.         }
  183.         return $this;
  184.     }
  185.     public function removeJob(Job $job): self
  186.     {
  187.         if ($this->jobs->removeElement($job)) {
  188.             // set the owning side to null (unless already changed)
  189.             if ($job->getMajorProfile() === $this) {
  190.                 $job->setMajorProfile(null);
  191.             }
  192.         }
  193.         return $this;
  194.     }
  195.     /**
  196.      * @return Collection<int, Job>
  197.      */
  198.     public function getJobMinors(): Collection
  199.     {
  200.         return $this->jobMinors;
  201.     }
  202.     public function addJobMinor(Job $jobMinor): self
  203.     {
  204.         if (!$this->jobMinors->contains($jobMinor)) {
  205.             $this->jobMinors[] = $jobMinor;
  206.             $jobMinor->setMinorProfile($this);
  207.         }
  208.         return $this;
  209.     }
  210.     public function removeJobMinor(Job $jobMinor): self
  211.     {
  212.         if ($this->jobMinors->removeElement($jobMinor)) {
  213.             // set the owning side to null (unless already changed)
  214.             if ($jobMinor->getMinorProfile() === $this) {
  215.                 $jobMinor->setMinorProfile(null);
  216.             }
  217.         }
  218.         return $this;
  219.     }
  220.     /**
  221.      * @return Collection<int, Job>
  222.      */
  223.     public function getJobFairs(): Collection
  224.     {
  225.         return $this->jobFairs;
  226.     }
  227.     public function addJobFair(Job $jobFair): self
  228.     {
  229.         if (!$this->jobFairs->contains($jobFair)) {
  230.             $this->jobFairs[] = $jobFair;
  231.             $jobFair->setFair($this);
  232.         }
  233.         return $this;
  234.     }
  235.     public function removeJobFair(Job $jobFair): self
  236.     {
  237.         if ($this->jobFairs->removeElement($jobFair)) {
  238.             // set the owning side to null (unless already changed)
  239.             if ($jobFair->getFair() === $this) {
  240.                 $jobFair->setFair(null);
  241.             }
  242.         }
  243.         return $this;
  244.     }
  245.     /**
  246.      * @return Collection<int, TwiceProfile>
  247.      */
  248.     public function getTwiceProfilesA(): Collection
  249.     {
  250.         return $this->twiceProfilesA;
  251.     }
  252.     public function addTwiceProfilesA(TwiceProfile $twiceProfilesA): self
  253.     {
  254.         if (!$this->twiceProfilesA->contains($twiceProfilesA)) {
  255.             $this->twiceProfilesA[] = $twiceProfilesA;
  256.             $twiceProfilesA->setProfileA($this);
  257.         }
  258.         return $this;
  259.     }
  260.     public function removeTwiceProfilesA(TwiceProfile $twiceProfilesA): self
  261.     {
  262.         if ($this->twiceProfilesA->removeElement($twiceProfilesA)) {
  263.             // set the owning side to null (unless already changed)
  264.             if ($twiceProfilesA->getProfileA() === $this) {
  265.                 $twiceProfilesA->setProfileA(null);
  266.             }
  267.         }
  268.         return $this;
  269.     }
  270.     /**
  271.      * @return Collection<int, TwiceProfile>
  272.      */
  273.     public function getTwiceProfilesB(): Collection
  274.     {
  275.         return $this->twiceProfilesB;
  276.     }
  277.     public function addTwiceProfileB(TwiceProfile $twiceProfileB): self
  278.     {
  279.         if (!$this->twiceProfilesB->contains($twiceProfileB)) {
  280.             $this->twiceProfilesB[] = $twiceProfileB;
  281.             $twiceProfileB->setProfileB($this);
  282.         }
  283.         return $this;
  284.     }
  285.     public function removeTwiceProfileB(TwiceProfile $twiceProfileB): self
  286.     {
  287.         if ($this->twiceProfilesB->removeElement($twiceProfileB)) {
  288.             // set the owning side to null (unless already changed)
  289.             if ($twiceProfileB->getProfileB() === $this) {
  290.                 $twiceProfileB->setProfileB(null);
  291.             }
  292.         }
  293.         return $this;
  294.     }
  295.     /**
  296.      * @return Collection<int, ProfilPositiveDescription>
  297.      */
  298.     public function getProfilPositiveDescriptions(): Collection
  299.     {
  300.         return $this->profilPositiveDescriptions;
  301.     }
  302.     public function addProfilPositiveDescription(ProfilPositiveDescription $profilPositiveDescription): self
  303.     {
  304.         if (!$this->profilPositiveDescriptions->contains($profilPositiveDescription)) {
  305.             $this->profilPositiveDescriptions[] = $profilPositiveDescription;
  306.             $profilPositiveDescription->setProfil($this);
  307.         }
  308.         return $this;
  309.     }
  310.     public function removeProfilPositiveDescription(ProfilPositiveDescription $profilPositiveDescription): self
  311.     {
  312.         if ($this->profilPositiveDescriptions->removeElement($profilPositiveDescription)) {
  313.             // set the owning side to null (unless already changed)
  314.             if ($profilPositiveDescription->getProfil() === $this) {
  315.                 $profilPositiveDescription->setProfil(null);
  316.             }
  317.         }
  318.         return $this;
  319.     }
  320.     /**
  321.      * @return Collection<int, ProfilNegativeDescription>
  322.      */
  323.     public function getProfilNegativeDescriptions(): Collection
  324.     {
  325.         return $this->profilNegativeDescriptions;
  326.     }
  327.     public function addProfilNegativeDescription(ProfilNegativeDescription $profilNegativeDescription): self
  328.     {
  329.         if (!$this->profilNegativeDescriptions->contains($profilNegativeDescription)) {
  330.             $this->profilNegativeDescriptions[] = $profilNegativeDescription;
  331.             $profilNegativeDescription->setProfil($this);
  332.         }
  333.         return $this;
  334.     }
  335.     public function removeProfilNegativeDescription(ProfilNegativeDescription $profilNegativeDescription): self
  336.     {
  337.         if ($this->profilNegativeDescriptions->removeElement($profilNegativeDescription)) {
  338.             // set the owning side to null (unless already changed)
  339.             if ($profilNegativeDescription->getProfil() === $this) {
  340.                 $profilNegativeDescription->setProfil(null);
  341.             }
  342.         }
  343.         return $this;
  344.     }
  345.     /**
  346.      * @return Collection<int, RBQuiz>
  347.      */
  348.     public function getRBQuizzes(): Collection
  349.     {
  350.         return $this->rBQuizzes;
  351.     }
  352.     public function addRBQuiz(RBQuiz $rBQuiz): self
  353.     {
  354.         if (!$this->rBQuizzes->contains($rBQuiz)) {
  355.             $this->rBQuizzes[] = $rBQuiz;
  356.             $rBQuiz->setRiasecProfile($this);
  357.         }
  358.         return $this;
  359.     }
  360.     public function removeRBQuiz(RBQuiz $rBQuiz): self
  361.     {
  362.         if ($this->rBQuizzes->removeElement($rBQuiz)) {
  363.             // set the owning side to null (unless already changed)
  364.             if ($rBQuiz->getRiasecProfile() === $this) {
  365.                 $rBQuiz->setRiasecProfile(null);
  366.             }
  367.         }
  368.         return $this;
  369.     }
  370.     /**
  371.      * @return Collection<int, UserRiasecProfile>
  372.      */
  373.     public function getUserRiasecProfiles(): Collection
  374.     {
  375.         return $this->userRiasecProfiles;
  376.     }
  377.     public function addUserRiasecProfile(UserRiasecProfile $userRiasecProfile): self
  378.     {
  379.         if (!$this->userRiasecProfiles->contains($userRiasecProfile)) {
  380.             $this->userRiasecProfiles[] = $userRiasecProfile;
  381.             $userRiasecProfile->setRiasecProfile($this);
  382.         }
  383.         return $this;
  384.     }
  385.     public function removeUserRiasecProfile(UserRiasecProfile $userRiasecProfile): self
  386.     {
  387.         if ($this->userRiasecProfiles->removeElement($userRiasecProfile)) {
  388.             // set the owning side to null (unless already changed)
  389.             if ($userRiasecProfile->getRiasecProfile() === $this) {
  390.                 $userRiasecProfile->setRiasecProfile(null);
  391.             }
  392.         }
  393.         return $this;
  394.     }
  395.     public function getMainletter(): ?string
  396.     {
  397.         return $this->mainletter;
  398.     }
  399.     public function setMainletter(?string $mainletter): self
  400.     {
  401.         $this->mainletter $mainletter;
  402.         return $this;
  403.     }
  404. }