src/Entity/Season.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Report\TaskList;
  4. use App\Entity\Task\MonitoringObjective;
  5. use App\Entity\Task\Objective;
  6. use App\Entity\Techcard\Techcard;
  7. use App\Repository\SeasonRepository;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\ORM\Mapping as ORM;
  11. /**
  12.  * @ORM\Entity(repositoryClass=SeasonRepository::class)
  13.  */
  14. class Season
  15. {
  16.     /**
  17.      * @ORM\Id
  18.      * @ORM\GeneratedValue
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\Column(type="string", length=255)
  24.      */
  25.     private $name;
  26.     /**
  27.      * @ORM\OneToMany(targetEntity=Techcard::class, mappedBy="season")
  28.      */
  29.     private $techcards;
  30.     /**
  31.      * @ORM\Column(type="boolean", nullable=true, options={"default" : true})
  32.      */
  33.     private $status;
  34.     /**
  35.      * @ORM\OneToMany(targetEntity=TaskList::class, mappedBy="season")
  36.      */
  37.     private $taskLists;
  38.     /**
  39.      * @ORM\OneToMany(targetEntity=Field::class, mappedBy="season")
  40.      */
  41.     private $fields;
  42.     /**
  43.      * @ORM\Column(type="boolean", nullable=true, options={"default":false})
  44.      */
  45.     private $remove;
  46.     /**
  47.      * @ORM\ManyToOne(targetEntity=CompanyGroup::class, inversedBy="seasons")
  48.      */
  49.     private $companyGroup;
  50.     /**
  51.      * @ORM\OneToMany(targetEntity=Objective::class, mappedBy="season")
  52.      */
  53.     private $objectives;
  54.     /**
  55.      * @ORM\OneToMany(targetEntity=MonitoringObjective::class, mappedBy="season")
  56.      */
  57.     private $monitoringObjectives;
  58.     public function __construct()
  59.     {
  60.         if(empty($this->id)){
  61.             $this->status true;
  62.             $this->remove false;
  63.         }
  64.         $this->techcards = new ArrayCollection();
  65.         $this->taskLists = new ArrayCollection();
  66.         $this->objectives = new ArrayCollection();
  67.         $this->monitoringObjectives = new ArrayCollection();
  68.     }
  69.     public function getId(): ?int
  70.     {
  71.         return $this->id;
  72.     }
  73.     public function getName(): ?string
  74.     {
  75.         return $this->name;
  76.     }
  77.     public function setName(string $name): self
  78.     {
  79.         $this->name $name;
  80.         return $this;
  81.     }
  82.     public function __toString()
  83.     {
  84.         return $this->name;
  85.     }
  86.     /**
  87.      * @return Collection|Techcard[]
  88.      */
  89.     public function getTechcards(): Collection
  90.     {
  91.         return $this->techcards;
  92.     }
  93.     public function addTechcard(Techcard $techcard): self
  94.     {
  95.         if (!$this->techcards->contains($techcard)) {
  96.             $this->techcards[] = $techcard;
  97.             $techcard->setSeason($this);
  98.         }
  99.         return $this;
  100.     }
  101.     public function removeTechcard(Techcard $techcard): self
  102.     {
  103.         if ($this->techcards->removeElement($techcard)) {
  104.             // set the owning side to null (unless already changed)
  105.             if ($techcard->getSeason() === $this) {
  106.                 $techcard->setSeason(null);
  107.             }
  108.         }
  109.         return $this;
  110.     }
  111.     public function removeAllTechcard()
  112.     {
  113. //        if($this->getFields()->count()) {
  114. //            foreach ($this->getTechcards() as $techcard) {
  115. //                $this->removeTechcard($techcard);
  116. //            }
  117. //        }
  118.     }
  119.     public function getStatus(): ?bool
  120.     {
  121.         return $this->status;
  122.     }
  123.     public function setStatus(?bool $status): self
  124.     {
  125.         $this->status $status;
  126.         return $this;
  127.     }
  128.     /**
  129.      * @return Collection|TaskList[]
  130.      */
  131.     public function getTaskLists(): Collection
  132.     {
  133.         return $this->taskLists;
  134.     }
  135.     public function addTaskList(TaskList $taskList): self
  136.     {
  137.         if (!$this->taskLists->contains($taskList)) {
  138.             $this->taskLists[] = $taskList;
  139.             $taskList->setSeason($this);
  140.         }
  141.         return $this;
  142.     }
  143.     public function removeTaskList(TaskList $taskList): self
  144.     {
  145.         if ($this->taskLists->removeElement($taskList)) {
  146.             // set the owning side to null (unless already changed)
  147.             if ($taskList->getSeason() === $this) {
  148.                 $taskList->setSeason(null);
  149.             }
  150.         }
  151.         return $this;
  152.     }
  153.     public function removeAllTaskList()
  154.     {
  155.         if($this->getTaskLists()->count()) {
  156.             foreach ($this->getTaskLists() as $item) {
  157.                 $this->removeTaskList($item);
  158.             }
  159.         }
  160.     }
  161.     /**
  162.      * @return Collection|Field[]
  163.      */
  164.     public function getFields(): Collection
  165.     {
  166.         return $this->fields;
  167.     }
  168.     public function addField(Field $field): self
  169.     {
  170.         if (!$this->fields->contains($field)) {
  171.             $this->fields[] = $field;
  172.             $field->setSeason($this);
  173.         }
  174.         return $this;
  175.     }
  176.     public function removeField(Field $field): self
  177.     {
  178.         if ($this->fields->removeElement($field)) {
  179.             // set the owning side to null (unless already changed)
  180.             if ($field->getSeason() === $this) {
  181.                 $field->setSeason(null);
  182.             }
  183.         }
  184.         return $this;
  185.     }
  186.     public function removeAllField()
  187.     {
  188.         if($this->getFields()->count()) {
  189.             foreach ($this->getFields() as $field) {
  190.                 $this->removeField($field);
  191.             }
  192.         }
  193.     }
  194.     public function isRemove(): ?bool
  195.     {
  196.         return $this->remove;
  197.     }
  198.     public function setRemove(?bool $remove): self
  199.     {
  200.         $this->remove $remove;
  201.         return $this;
  202.     }
  203.     public function getCompanyGroup(): ?CompanyGroup
  204.     {
  205.         return $this->companyGroup;
  206.     }
  207.     public function setCompanyGroup(?CompanyGroup $companyGroup): self
  208.     {
  209.         $this->companyGroup $companyGroup;
  210.         return $this;
  211.     }
  212.     /**
  213.      * @return Collection<int, Objective>
  214.      */
  215.     public function getObjectives(): Collection
  216.     {
  217.         return $this->objectives;
  218.     }
  219.     public function addObjective(Objective $objective): self
  220.     {
  221.         if (!$this->objectives->contains($objective)) {
  222.             $this->objectives[] = $objective;
  223.             $objective->setSeason($this);
  224.         }
  225.         return $this;
  226.     }
  227.     public function removeObjective(Objective $objective): self
  228.     {
  229.         if ($this->objectives->removeElement($objective)) {
  230.             // set the owning side to null (unless already changed)
  231.             if ($objective->getSeason() === $this) {
  232.                 $objective->setSeason(null);
  233.             }
  234.         }
  235.         return $this;
  236.     }
  237.     /**
  238.      * @return Collection<int, MonitoringObjective>
  239.      */
  240.     public function getMonitoringObjectives(): Collection
  241.     {
  242.         return $this->monitoringObjectives;
  243.     }
  244.     public function addMonitoringObjective(MonitoringObjective $monitoringObjective): self
  245.     {
  246.         if (!$this->monitoringObjectives->contains($monitoringObjective)) {
  247.             $this->monitoringObjectives[] = $monitoringObjective;
  248.             $monitoringObjective->setSeason($this);
  249.         }
  250.         return $this;
  251.     }
  252.     public function removeMonitoringObjective(MonitoringObjective $monitoringObjective): self
  253.     {
  254.         if ($this->monitoringObjectives->removeElement($monitoringObjective)) {
  255.             // set the owning side to null (unless already changed)
  256.             if ($monitoringObjective->getSeason() === $this) {
  257.                 $monitoringObjective->setSeason(null);
  258.             }
  259.         }
  260.         return $this;
  261.     }
  262. }