src/Entity/Quiz/RiasecBigFive/RBQuiz.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Quiz\RiasecBigFive;
  3. use App\Entity\EntityIdentifier;
  4. use App\Entity\Profil\BigFiveProfile;
  5. use App\Entity\Profil\Profil;
  6. use App\Entity\UserRBQuizResponse;
  7. use App\Repository\Quiz\RiasecBigFive\RBQuizRepository;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Knp\DoctrineBehaviors\Model as ORMBehaviors;
  12. /**
  13.  * @ORM\Entity(repositoryClass=RBQuizRepository::class)
  14.  * @ORM\HasLifecycleCallbacks()
  15.  */
  16. class RBQuiz
  17. {
  18.     
  19.     use ORMBehaviors\Translatable\Translatable;
  20.     
  21.     use EntityIdentifier;
  22.     
  23.     /**
  24.      * @ORM\Id
  25.      * @ORM\GeneratedValue
  26.      * @ORM\Column(type="integer")
  27.      */
  28.     private $id;
  29.     /**
  30.      * @ORM\Column(type="string", length=255, nullable=true)
  31.      */
  32.     private $quizType;
  33.     /**
  34.      * @ORM\ManyToOne(targetEntity=Profil::class, inversedBy="rBQuizzes")
  35.      */
  36.     private $riasecProfile;
  37.     /**
  38.      * @ORM\ManyToOne(targetEntity=BigFiveProfile::class, inversedBy="rBQuizzes")
  39.      */
  40.     private $bigFiveProfile;
  41.     /**
  42.      * @ORM\Column(type="boolean", nullable=true)
  43.      */
  44.     private $normalWeighting;
  45.     
  46.     /**
  47.      * @ORM\OneToMany(targetEntity=RBQuizTranslation::class, mappedBy="translatable", cascade={"persist"})
  48.      */
  49.     protected $newTranslations;
  50.     /**
  51.      * @ORM\OneToMany(targetEntity=UserRBQuizResponse::class, mappedBy="rbQuiz")
  52.      */
  53.     private $userRBQuizResponses;
  54.     /**
  55.      * @ORM\Column(type="boolean", nullable=true)
  56.      */
  57.     private $active;
  58.     public function __construct()
  59.     {
  60.         $this->userRBQuizResponses = new ArrayCollection();
  61.     }
  62.     
  63.     /**
  64.      * @ORM\PostLoad()
  65.      */
  66.     public function init() {
  67.                                             $this->mergeNewTranslations();
  68.                                             $this->currentLocale = \Locale::getDefault();
  69.                                         }
  70.     
  71.     public function __call($name$arguments) {
  72.                                             $reflect = new \ReflectionClass(RBQuizTranslation::class);
  73.                                             $privateProperties $reflect->getProperties(\ReflectionProperty::IS_PRIVATE);
  74.                                             
  75.                                             foreach ($privateProperties as $property) {
  76.                                                 if($property->getName() == $name) {
  77.                                                     return $this->translate()->{"get" ucfirst($name)}();
  78.                                                 }
  79.                                             }
  80.                                             
  81.                                             return "";
  82.                                         }
  83.     public function getId(): ?int
  84.     {
  85.         return $this->id;
  86.     }
  87.     public function getQuizType(): ?string
  88.     {
  89.         return $this->quizType;
  90.     }
  91.     public function setQuizType(?string $quizType): self
  92.     {
  93.         $this->quizType $quizType;
  94.         return $this;
  95.     }
  96.     public function getRiasecProfile(): ?Profil
  97.     {
  98.         return $this->riasecProfile;
  99.     }
  100.     public function setRiasecProfile(?Profil $riasecProfile): self
  101.     {
  102.         $this->riasecProfile $riasecProfile;
  103.         return $this;
  104.     }
  105.     public function getBigFiveProfile(): ?BigFiveProfile
  106.     {
  107.         return $this->bigFiveProfile;
  108.     }
  109.     public function setBigFiveProfile(?BigFiveProfile $bigFiveProfile): self
  110.     {
  111.         $this->bigFiveProfile $bigFiveProfile;
  112.         return $this;
  113.     }
  114.     public function isNormalWeighting(): ?bool
  115.     {
  116.         return $this->normalWeighting;
  117.     }
  118.     public function setNormalWeighting(?bool $normalWeighting): self
  119.     {
  120.         $this->normalWeighting $normalWeighting;
  121.         return $this;
  122.     }
  123.     /**
  124.      * @return Collection<int, UserRBQuizResponse>
  125.      */
  126.     public function getUserRBQuizResponses(): Collection
  127.     {
  128.         return $this->userRBQuizResponses;
  129.     }
  130.     public function addUserRBQuizResponse(UserRBQuizResponse $userRBQuizResponse): self
  131.     {
  132.         if (!$this->userRBQuizResponses->contains($userRBQuizResponse)) {
  133.             $this->userRBQuizResponses[] = $userRBQuizResponse;
  134.             $userRBQuizResponse->setRbQuiz($this);
  135.         }
  136.         return $this;
  137.     }
  138.     public function removeUserRBQuizResponse(UserRBQuizResponse $userRBQuizResponse): self
  139.     {
  140.         if ($this->userRBQuizResponses->removeElement($userRBQuizResponse)) {
  141.             // set the owning side to null (unless already changed)
  142.             if ($userRBQuizResponse->getRbQuiz() === $this) {
  143.                 $userRBQuizResponse->setRbQuiz(null);
  144.             }
  145.         }
  146.         return $this;
  147.     }
  148.     public function isActive(): ?bool
  149.     {
  150.         return $this->active;
  151.     }
  152.     public function setActive(?bool $active): self
  153.     {
  154.         $this->active $active;
  155.         return $this;
  156.     }
  157. }