src/Entity/Quater.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\Period;
  4. use App\Repository\QuaterRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9. * @ORM\Entity(repositoryClass=QuaterRepository::class)
  10. */
  11. class Quater
  12. {
  13. use Period;
  14. /**
  15. * @ORM\Id
  16. * @ORM\GeneratedValue
  17. * @ORM\Column(type="integer")
  18. */
  19. private $id;
  20. /**
  21. * @ORM\ManyToOne(targetEntity=SchoolYear::class, inversedBy="quaters")
  22. * @ORM\JoinColumn(nullable=false)
  23. */
  24. private $schoolYear;
  25. /**
  26. * @ORM\OneToMany(targetEntity=Sequence::class, mappedBy="quater", orphanRemoval=true)
  27. */
  28. private $sequences;
  29. public function __construct()
  30. {
  31. $this->sequences = new ArrayCollection();
  32. }
  33. public function getId(): ?int
  34. {
  35. return $this->id;
  36. }
  37. public function getSchoolYear(): ?SchoolYear
  38. {
  39. return $this->schoolYear;
  40. }
  41. public function setSchoolYear(?SchoolYear $schoolYear): self
  42. {
  43. $this->schoolYear = $schoolYear;
  44. return $this;
  45. }
  46. /**
  47. * @return Collection|Sequence[]
  48. */
  49. public function getSequences(): Collection
  50. {
  51. return $this->sequences;
  52. }
  53. public function addSequence(Sequence $sequence): self
  54. {
  55. if (!$this->sequences->contains($sequence)) {
  56. $this->sequences[] = $sequence;
  57. $sequence->setQuater($this);
  58. }
  59. return $this;
  60. }
  61. public function removeSequence(Sequence $sequence): self
  62. {
  63. if ($this->sequences->removeElement($sequence)) {
  64. // set the owning side to null (unless already changed)
  65. if ($sequence->getQuater() === $this) {
  66. $sequence->setQuater(null);
  67. }
  68. }
  69. return $this;
  70. }
  71. public function unable()
  72. {
  73. $this->setActivated(true);
  74. if (count($this->getSequences()) > 0)
  75. $this->getSequences()[0]->unable();
  76. }
  77. public function disable()
  78. {
  79. $this->setActivated(false);
  80. foreach ($this->getSequences() as $sequence) {
  81. $sequence->disable();
  82. }
  83. }
  84. }