src/Entity/Profil/BigFiveProfile.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Profil;
  3. use App\Entity\EntityIdentifier;
  4. use App\Entity\Quiz\RiasecBigFive\RBQuiz;
  5. use App\Repository\Profil\BigFiveProfileRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Knp\DoctrineBehaviors\Model as ORMBehaviors;
  10. /**
  11.  * @ORM\Entity(repositoryClass=BigFiveProfileRepository::class)
  12.  * @ORM\HasLifecycleCallbacks()
  13.  */
  14. class BigFiveProfile
  15. {
  16.     
  17.     use ORMBehaviors\Translatable\Translatable;
  18.     
  19.     use EntityIdentifier;
  20.     
  21.     /**
  22.      * @ORM\Id
  23.      * @ORM\GeneratedValue
  24.      * @ORM\Column(type="integer")
  25.      */
  26.     private $id;
  27.     
  28.     /**
  29.      * @ORM\OneToMany(targetEntity=BigFiveProfileTranslation::class, mappedBy="translatable", cascade={"persist"})
  30.      */
  31.     protected $newTranslations;
  32.     /**
  33.      * @ORM\Column(type="string", length=255, nullable=true)
  34.      */
  35.     private $color;
  36.     /**
  37.      * @ORM\OneToMany(targetEntity=RBQuiz::class, mappedBy="bigFiveProfile")
  38.      */
  39.     private $rBQuizzes;
  40.     /**
  41.      * @ORM\Column(type="integer", nullable=true)
  42.      */
  43.     private $position;
  44.     public function __construct()
  45.     {
  46.         $this->rBQuizzes = new ArrayCollection();
  47.     }
  48.     
  49.     /**
  50.      * @ORM\PostLoad()
  51.      */
  52.     public function init() {
  53.                                             $this->mergeNewTranslations();
  54.                                             $this->currentLocale = \Locale::getDefault();
  55.                                         }
  56.     public function getId(): ?int
  57.     {
  58.         return $this->id;
  59.     }
  60.     public function getColor(): ?string
  61.     {
  62.         return $this->color;
  63.     }
  64.     public function setColor(?string $color): self
  65.     {
  66.         $this->color $color;
  67.         return $this;
  68.     }
  69.     
  70.     public function __call($name$arguments) {
  71.                                             $reflect = new \ReflectionClass(BigFiveProfileTranslation::class);
  72.                                             $privateProperties $reflect->getProperties(\ReflectionProperty::IS_PRIVATE);
  73.                                             
  74.                                             foreach ($privateProperties as $property) {
  75.                                                 if($property->getName() == $name) {
  76.                                                     return $this->translate()->{"get" ucfirst($name)}();
  77.                                                 }
  78.                                             }
  79.                                             
  80.                                             return "";
  81.                                         }
  82.     /**
  83.      * @return Collection<int, RBQuiz>
  84.      */
  85.     public function getRBQuizzes(): Collection
  86.     {
  87.         return $this->rBQuizzes;
  88.     }
  89.     public function addRBQuiz(RBQuiz $rBQuiz): self
  90.     {
  91.         if (!$this->rBQuizzes->contains($rBQuiz)) {
  92.             $this->rBQuizzes[] = $rBQuiz;
  93.             $rBQuiz->setBigFiveProfile($this);
  94.         }
  95.         return $this;
  96.     }
  97.     public function removeRBQuiz(RBQuiz $rBQuiz): self
  98.     {
  99.         if ($this->rBQuizzes->removeElement($rBQuiz)) {
  100.             // set the owning side to null (unless already changed)
  101.             if ($rBQuiz->getBigFiveProfile() === $this) {
  102.                 $rBQuiz->setBigFiveProfile(null);
  103.             }
  104.         }
  105.         return $this;
  106.     }
  107.     public function getPosition(): ?int
  108.     {
  109.         return $this->position;
  110.     }
  111.     public function setPosition(?int $position): self
  112.     {
  113.         $this->position $position;
  114.         return $this;
  115.     }
  116.     
  117. }