src/Entity/Ciclo.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Core\Entity\Institucion\Programa;
  4. use App\Repository\CicloRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9. * @ORM\Entity(repositoryClass=CicloRepository::class)
  10. */
  11. class Ciclo
  12. {
  13. const JSON_FIELDS = ['id', 'nombre', 'estado'];
  14. /**
  15. * @ORM\Id
  16. * @ORM\GeneratedValue
  17. * @ORM\Column(type="integer")
  18. */
  19. private $id;
  20. /**
  21. * @ORM\OneToOne(targetEntity=Ciclo::class, mappedBy="SiguienteCiclo", fetch="LAZY")
  22. */
  23. private ?Ciclo $CicloAnterior;
  24. /**
  25. * @ORM\OneToOne(targetEntity=Ciclo::class, inversedBy="CicloAnterior", cascade={"persist"}, fetch="LAZY")
  26. * @ORM\JoinColumn(nullable=true, onDelete= "SET NULL")
  27. */
  28. private ?Ciclo $SiguienteCiclo;
  29. /**
  30. * @ORM\OneToMany(targetEntity=Ciclo::class, mappedBy="CicloClon")
  31. */
  32. private $ciclos;
  33. /**
  34. * @ORM\ManyToOne(targetEntity=Ciclo::class, inversedBy="ciclos")
  35. */
  36. private ?Ciclo $CicloClon;
  37. /**
  38. * @ORM\Column(type="date", nullable=true)
  39. */
  40. private ?\DateTimeInterface $fechaInicio;
  41. /**
  42. * @ORM\Column(type="date", nullable=true)
  43. */
  44. private ?\DateTimeInterface $fechaFin;
  45. /**
  46. * @ORM\Column(type="integer")
  47. */
  48. private ?int $estado;
  49. /*
  50. * 0 = Inactivo
  51. * 1 = Activo
  52. * 2 = Archivado
  53. */
  54. /**
  55. * @ORM\ManyToOne(targetEntity=TipoCiclo::class, inversedBy="ciclos")
  56. */
  57. private ?TipoCiclo $tipoCiclo;
  58. /**
  59. * @ORM\Column(type="string", length=100, nullable=true)
  60. */
  61. private ?string $nombre;
  62. /**
  63. * @ORM\OneToMany(targetEntity=Programa::class, mappedBy="ciclo")
  64. */
  65. private $programas;
  66. public function __construct()
  67. {
  68. $this->ciclos = new ArrayCollection();
  69. $this->programas = new ArrayCollection();
  70. }
  71. public function getId(): ?int
  72. {
  73. return $this->id;
  74. }
  75. public function getCicloAnterior(): ?self
  76. {
  77. return $this->CicloAnterior;
  78. }
  79. public function setCicloAnterior(?self $CicloAnterior): self
  80. {
  81. // No hago nada si quiero hacer un anillo
  82. if ($CicloAnterior === $this) {
  83. return $this;
  84. }
  85. if ($this->CicloAnterior && $this->getCicloAnterior()->getSiguienteCiclo() === $this) {
  86. $this->getCicloAnterior()->setSiguienteCiclo(null);
  87. }
  88. $this->CicloAnterior = $CicloAnterior;
  89. // set the owning side of the relation if necessary
  90. if ($CicloAnterior && $CicloAnterior->getSiguienteCiclo() !== $this) {
  91. $CicloAnterior->setSiguienteCiclo($this);
  92. }
  93. return $this;
  94. }
  95. public function getSiguienteCiclo(): ?self
  96. {
  97. return $this->SiguienteCiclo;
  98. }
  99. public function setSiguienteCiclo(?self $SiguienteCiclo): self
  100. {
  101. // No hago nada si quiero hacer un anillo
  102. if ($SiguienteCiclo === $this) {
  103. return $this;
  104. }
  105. if ($this->SiguienteCiclo && $this->getSiguienteCiclo()->getCicloAnterior() === $this) {
  106. $this->getSiguienteCiclo()->setCicloAnterior(null);
  107. }
  108. $this->SiguienteCiclo = $SiguienteCiclo;
  109. if ($SiguienteCiclo && $SiguienteCiclo->getCicloAnterior() !== $this) {
  110. $SiguienteCiclo->setCicloAnterior($this);
  111. }
  112. return $this;
  113. }
  114. /**
  115. * @return Collection<int, self>
  116. */
  117. public function getCiclos(): Collection
  118. {
  119. return $this->ciclos;
  120. }
  121. public function addCiclo(self $ciclo): self
  122. {
  123. if (!$this->ciclos->contains($ciclo)) {
  124. $this->ciclos[] = $ciclo;
  125. $ciclo->setCicloClon($this);
  126. }
  127. return $this;
  128. }
  129. public function removeCiclo(self $ciclo): self
  130. {
  131. if ($this->ciclos->removeElement($ciclo)) {
  132. // set the owning side to null (unless already changed)
  133. if ($ciclo->getCicloClon() === $this) {
  134. $ciclo->setCicloClon(null);
  135. }
  136. }
  137. return $this;
  138. }
  139. public function getCicloClon(): ?self
  140. {
  141. return $this->CicloClon;
  142. }
  143. public function setCicloClon(?self $CicloClon): self
  144. {
  145. $this->CicloClon = $CicloClon;
  146. return $this;
  147. }
  148. public function getFechaInicio(): ?\DateTimeInterface
  149. {
  150. return $this->fechaInicio;
  151. }
  152. public function setFechaInicio(?\DateTimeInterface $fechaInicio): self
  153. {
  154. $this->fechaInicio = $fechaInicio;
  155. return $this;
  156. }
  157. public function getFechaFin(): ?\DateTimeInterface
  158. {
  159. return $this->fechaFin;
  160. }
  161. public function setFechaFin(?\DateTimeInterface $fechaFin): self
  162. {
  163. $this->fechaFin = $fechaFin;
  164. return $this;
  165. }
  166. public function getEstado(): ?int
  167. {
  168. return $this->estado;
  169. }
  170. public function setEstado(int $estado): self
  171. {
  172. $this->estado = $estado;
  173. return $this;
  174. }
  175. public function getTipoCiclo(): ?TipoCiclo
  176. {
  177. return $this->tipoCiclo;
  178. }
  179. public function setTipoCiclo(?TipoCiclo $tipoCiclo): self
  180. {
  181. $this->tipoCiclo = $tipoCiclo;
  182. return $this;
  183. }
  184. public function getNombre(): ?string
  185. {
  186. return $this->nombre;
  187. }
  188. public function setNombre(?string $nombre): self
  189. {
  190. $this->nombre = $nombre;
  191. return $this;
  192. }
  193. /**
  194. * @return Collection|Programa[]
  195. */
  196. public function getProgramas(): Collection
  197. {
  198. return $this->programas;
  199. }
  200. public function addPrograma(Programa $programa): self
  201. {
  202. if (!$this->programas->contains($programa)) {
  203. $this->programas[] = $programa;
  204. $programa->setCiclo($this);
  205. }
  206. return $this;
  207. }
  208. public function removePrograma(Programa $programa): self
  209. {
  210. if ($this->programas->removeElement($programa)) {
  211. // set the owning side to null (unless already changed)
  212. if ($programa->getCiclo() === $this) {
  213. $programa->setCiclo(null);
  214. }
  215. }
  216. return $this;
  217. }
  218. }