src/Entity/Kpi.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\KpiRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. /**
  9.  * @ORM\Entity(repositoryClass=KpiRepository::class)
  10.  */
  11. class Kpi
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      * @Groups("main")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\Column(type="string", length=32)
  22.      * @Groups("main")
  23.      */
  24.     private $name;
  25.     /**
  26.      * @ORM\Column(type="string", length=255, nullable=true)
  27.      * @Groups("main")
  28.      */
  29.     private $description;
  30.     /**
  31.      * @ORM\Column(type="integer")
  32.      * @Groups("main")
  33.      */
  34.     private $position;
  35.     /**
  36.      * @ORM\OneToMany(targetEntity=ExerciseSimpleAnswer::class, mappedBy="kpi")
  37.      * @Groups("main")
  38.      */
  39.     private $exerciseSimpleAnswers;
  40.     /**
  41.      * @ORM\OneToMany(targetEntity=ExerciseSorting::class, mappedBy="kpi")
  42.      * @Groups("main")
  43.      */
  44.     private $exerciseSortings;
  45.     /**
  46.      * @ORM\OneToMany(targetEntity=ExerciseResult::class, mappedBy="kpi")
  47.      * @Groups("main")
  48.      */
  49.     private $exerciseResults;
  50.     public function __construct()
  51.     {
  52.         $this->exerciseSimpleAnswers = new ArrayCollection();
  53.         if(is_null($this->getPosition())){
  54.             $this->setPosition(0);
  55.         }
  56.         $this->exerciseSortings = new ArrayCollection();
  57.         $this->exerciseResults = new ArrayCollection();
  58.     }
  59.     public function getId(): ?int
  60.     {
  61.         return $this->id;
  62.     }
  63.     public function getName(): ?string
  64.     {
  65.         return $this->name;
  66.     }
  67.     public function setName(string $name): self
  68.     {
  69.         $this->name $name;
  70.         return $this;
  71.     }
  72.     public function getDescription(): ?string
  73.     {
  74.         return $this->description;
  75.     }
  76.     public function setDescription(?string $description): self
  77.     {
  78.         $this->description $description;
  79.         return $this;
  80.     }
  81.     public function getPosition(): ?int
  82.     {
  83.         return $this->position;
  84.     }
  85.     public function setPosition(int $position): self
  86.     {
  87.         $this->position $position;
  88.         return $this;
  89.     }
  90.     /**
  91.      * @return Collection|ExerciseSimpleAnswer[]
  92.      */
  93.     public function getExerciseSimpleAnswers(): Collection
  94.     {
  95.         return $this->exerciseSimpleAnswers;
  96.     }
  97.     public function addExerciseSimpleAnswer(ExerciseSimpleAnswer $exerciseSimpleAnswer): self
  98.     {
  99.         if (!$this->exerciseSimpleAnswers->contains($exerciseSimpleAnswer)) {
  100.             $this->exerciseSimpleAnswers[] = $exerciseSimpleAnswer;
  101.             $exerciseSimpleAnswer->setKpi($this);
  102.         }
  103.         return $this;
  104.     }
  105.     public function removeExerciseSimpleAnswer(ExerciseSimpleAnswer $exerciseSimpleAnswer): self
  106.     {
  107.         if ($this->exerciseSimpleAnswers->removeElement($exerciseSimpleAnswer)) {
  108.             // set the owning side to null (unless already changed)
  109.             if ($exerciseSimpleAnswer->getKpi() === $this) {
  110.                 $exerciseSimpleAnswer->setKpi(null);
  111.             }
  112.         }
  113.         return $this;
  114.     }
  115.     public function __toString()
  116.     {
  117.         return $this->getName();
  118.     }
  119.     /**
  120.      * @return Collection|ExerciseSorting[]
  121.      */
  122.     public function getExerciseSortings(): Collection
  123.     {
  124.         return $this->exerciseSortings;
  125.     }
  126.     public function addExerciseSorting(ExerciseSorting $exerciseSorting): self
  127.     {
  128.         if (!$this->exerciseSortings->contains($exerciseSorting)) {
  129.             $this->exerciseSortings[] = $exerciseSorting;
  130.             $exerciseSorting->setKpi($this);
  131.         }
  132.         return $this;
  133.     }
  134.     public function removeExerciseSorting(ExerciseSorting $exerciseSorting): self
  135.     {
  136.         if ($this->exerciseSortings->removeElement($exerciseSorting)) {
  137.             // set the owning side to null (unless already changed)
  138.             if ($exerciseSorting->getKpi() === $this) {
  139.                 $exerciseSorting->setKpi(null);
  140.             }
  141.         }
  142.         return $this;
  143.     }
  144.     /**
  145.      * @return Collection|ExerciseResult[]
  146.      */
  147.     public function getExerciseResults(): Collection
  148.     {
  149.         return $this->exerciseResults;
  150.     }
  151.     public function addExerciseResult(ExerciseResult $exerciseResult): self
  152.     {
  153.         if (!$this->exerciseResults->contains($exerciseResult)) {
  154.             $this->exerciseResults[] = $exerciseResult;
  155.             $exerciseResult->setKpi($this);
  156.         }
  157.         return $this;
  158.     }
  159.     public function removeExerciseResult(ExerciseResult $exerciseResult): self
  160.     {
  161.         if ($this->exerciseResults->removeElement($exerciseResult)) {
  162.             // set the owning side to null (unless already changed)
  163.             if ($exerciseResult->getKpi() === $this) {
  164.                 $exerciseResult->setKpi(null);
  165.             }
  166.         }
  167.         return $this;
  168.     }
  169. }