src/Entity/Curso.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. /**
  9. * @ORM\Entity
  10. * @ORM\Table(name="curso", indexes={@ORM\Index(name="idExternoIndex", columns={"id_externo"})})
  11. */
  12. class Curso extends BaseEntity
  13. {
  14. /**
  15. * @ORM\Id
  16. * @ORM\Column(type="integer")
  17. * @ORM\GeneratedValue(strategy="AUTO")
  18. */
  19. private $id;
  20. /**
  21. * @ORM\Column(type="string", nullable=true, name="id_externo")
  22. */
  23. private $idExterno;
  24. /**
  25. * @ORM\Column(type="json", nullable=true)
  26. */
  27. private $nombre;
  28. /**
  29. * @ORM\Column(type="json", nullable=true)
  30. */
  31. private $descripcion;
  32. /**
  33. * @ORM\Column(type="json", nullable=true)
  34. */
  35. private $area;
  36. /**
  37. * @ORM\Column(type="json", nullable=true)
  38. */
  39. private $familia;
  40. /**
  41. * @ORM\Column(type="string", length=2048, nullable=true, name="url_programa")
  42. */
  43. private ?string $urlPrograma = null;
  44. /**
  45. * @ORM\Column(type="datetime", nullable=true, name="deleted_at")
  46. */
  47. private $deletedAt;
  48. /**
  49. * @ORM\Column(type="datetime", nullable=false, name="updated_at", options={"default":"2024-01-01 00:00:00"})
  50. * @Gedmo\Timestampable(on="update")
  51. */
  52. private $updatedAt;
  53. /**
  54. * @ORM\Column(type="datetime", nullable=false, name="created_at", options={"default":"2024-01-01 00:00:00"})
  55. * @Gedmo\Timestampable(on="create")
  56. */
  57. private $createdAt;
  58. /**
  59. * @ORM\OneToMany(targetEntity=\App\Entity\SolicitudAccionFormativa::class, mappedBy="curso")
  60. */
  61. private $solicitudAccionFormativas;
  62. /**
  63. * @ORM\ManyToOne(targetEntity=\App\Entity\EntidadColaboradora::class, inversedBy="curso")
  64. * @ORM\JoinColumn(name="entidad_colaboradora_id", referencedColumnName="id")
  65. */
  66. private $entidadColaboradora;
  67. public function __construct()
  68. {
  69. $this->solicitudAccionFormativas = new ArrayCollection();
  70. }
  71. public function getId(): ?int
  72. {
  73. return $this->id;
  74. }
  75. public function getIdExterno(): ?string
  76. {
  77. return $this->idExterno;
  78. }
  79. public function setIdExterno(?string $idExterno): static
  80. {
  81. $this->idExterno = $idExterno;
  82. return $this;
  83. }
  84. public function getNombre(): ?array
  85. {
  86. return $this->nombre;
  87. }
  88. public function setNombre(?array $nombre): static
  89. {
  90. $this->nombre = $nombre;
  91. return $this;
  92. }
  93. /**
  94. * Devuelve el nombre del curso para un locale concreto, con fallback a 'ca' y al
  95. * primer valor disponible. Centraliza el patron getNombre()[$locale] para evitar
  96. * notices/undefined index repartidos en SUT (BUG-845 fix).
  97. */
  98. public function getNombrePorLocale(?string $locale = null): ?string
  99. {
  100. $nombres = $this->nombre;
  101. if (!is_array($nombres) || empty($nombres)) {
  102. return null;
  103. }
  104. if ($locale !== null && isset($nombres[$locale])) {
  105. return (string) $nombres[$locale];
  106. }
  107. if (isset($nombres['ca'])) {
  108. return (string) $nombres['ca'];
  109. }
  110. $first = reset($nombres);
  111. return $first === false ? null : (string) $first;
  112. }
  113. public function getDescripcion(): ?array
  114. {
  115. return $this->descripcion;
  116. }
  117. public function setDescripcion(?array $descripcion): static
  118. {
  119. $this->descripcion = $descripcion;
  120. return $this;
  121. }
  122. public function getArea(): ?array
  123. {
  124. return $this->area;
  125. }
  126. public function setArea(?array $area): static
  127. {
  128. $this->area = $area;
  129. return $this;
  130. }
  131. public function getFamilia(): ?array
  132. {
  133. return $this->familia;
  134. }
  135. public function setFamilia(?array $familia): static
  136. {
  137. $this->familia = $familia;
  138. return $this;
  139. }
  140. public function getDeletedAt(): ?\DateTimeInterface
  141. {
  142. return $this->deletedAt;
  143. }
  144. public function setDeletedAt(?\DateTimeInterface $deletedAt): static
  145. {
  146. $this->deletedAt = $deletedAt;
  147. return $this;
  148. }
  149. public function getUpdatedAt(): ?\DateTimeInterface
  150. {
  151. return $this->updatedAt;
  152. }
  153. public function setUpdatedAt(\DateTimeInterface $updatedAt): static
  154. {
  155. $this->updatedAt = $updatedAt;
  156. return $this;
  157. }
  158. public function getCreatedAt(): ?\DateTimeInterface
  159. {
  160. return $this->createdAt;
  161. }
  162. public function setCreatedAt(\DateTimeInterface $createdAt): static
  163. {
  164. $this->createdAt = $createdAt;
  165. return $this;
  166. }
  167. /**
  168. * @return Collection<int, SolicitudAccionFormativa>
  169. */
  170. public function getSolicitudAccionFormativas(): Collection
  171. {
  172. return $this->solicitudAccionFormativas;
  173. }
  174. public function addSolicitudAccionFormativa(SolicitudAccionFormativa $solicitudAccionFormativa): static
  175. {
  176. if (!$this->solicitudAccionFormativas->contains($solicitudAccionFormativa)) {
  177. $this->solicitudAccionFormativas->add($solicitudAccionFormativa);
  178. $solicitudAccionFormativa->setCurso($this);
  179. }
  180. return $this;
  181. }
  182. public function removeSolicitudAccionFormativa(SolicitudAccionFormativa $solicitudAccionFormativa): static
  183. {
  184. if ($this->solicitudAccionFormativas->removeElement($solicitudAccionFormativa)) {
  185. // set the owning side to null (unless already changed)
  186. if ($solicitudAccionFormativa->getCurso() === $this) {
  187. $solicitudAccionFormativa->setCurso(null);
  188. }
  189. }
  190. return $this;
  191. }
  192. public function getEntidadColaboradora(): ?EntidadColaboradora
  193. {
  194. return $this->entidadColaboradora;
  195. }
  196. public function setEntidadColaboradora(?EntidadColaboradora $entidadColaboradora): static
  197. {
  198. $this->entidadColaboradora = $entidadColaboradora;
  199. return $this;
  200. }
  201. public function getUrlPrograma(): ?string
  202. {
  203. return $this->urlPrograma;
  204. }
  205. public function setUrlPrograma(?string $urlPrograma): static
  206. {
  207. $this->urlPrograma = $urlPrograma;
  208. return $this;
  209. }
  210. }