src/Core/Entity/Institucion/Institucion.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Core\Entity\Institucion;
  3. use App\Core\Entity\Color;
  4. use App\Core\Repository\Institucion\InstitucionRepository;
  5. use App\Core\Entity\Institucion\DirectorInstitucion;
  6. use App\Core\Entity\Institucion\Campus;
  7. use App\Entity\InvitacionInstitucion;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Symfony\Component\HttpFoundation\File\File;
  12. use Symfony\Component\HttpFoundation\File\UploadedFile;
  13. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  14. /**
  15. * @ORM\Entity(repositoryClass=InstitucionRepository::class)
  16. * @Vich\Uploadable()
  17. */
  18. class Institucion
  19. {
  20. const JSON_FIELDS = ['id', 'nombre', 'sobreNosotros', 'paginaWeb', 'directoresInstitucion' => ['id', 'director' => ['id']], 'estado', 'imgPortadaName', 'imgInstitucionName', 'campuses' => ['id', 'nombre', 'descripcion', 'programas' => ['id', 'nombre', 'ciclos']]];
  21. /**
  22. * @ORM\Id
  23. * @ORM\GeneratedValue
  24. * @ORM\Column(type="integer")
  25. */
  26. private $id;
  27. /**
  28. * @ORM\Column(type="string", length=100)
  29. */
  30. private $nombre;
  31. /**
  32. * @ORM\Column(type="text")
  33. */
  34. private $sobreNosotros;
  35. /**
  36. * @ORM\Column(type="string", length=255, nullable=true)
  37. */
  38. private $paginaWeb;
  39. /**
  40. * @ORM\OneToMany(targetEntity=DirectorInstitucion::class, mappedBy="institucion")
  41. */
  42. private $directoresInstitucion;
  43. /**
  44. * @ORM\Column(type="integer")
  45. */
  46. private $estado;
  47. /**
  48. * NOTE: This is not a mapped field of entity metadata, just a simple property.
  49. *
  50. * @Vich\UploadableField(mapping="portada_de_institucion", fileNameProperty="imgPortadaName", size="imgPortadaSize")
  51. *
  52. * @var File|null
  53. */
  54. private $imgPortada;
  55. /**
  56. * @ORM\Column(type="string", length=200, nullable=true)
  57. *
  58. * @var string|null
  59. */
  60. private $imgPortadaName;
  61. /**
  62. * @ORM\Column(type="integer", nullable=true)
  63. *
  64. * @var int|null
  65. */
  66. private $imgPortadaSize;
  67. /**
  68. * NOTE: This is not a mapped field of entity metadata, just a simple property.
  69. *
  70. * @Vich\UploadableField(mapping="perfil_de_institucion", fileNameProperty="imgInstitucionName", size="imgInstitucionSize")
  71. *
  72. * @var File|null
  73. */
  74. private $imgInstitucion;
  75. /**
  76. * @ORM\Column(type="string", length=200, nullable=true)
  77. *
  78. * @var string|null
  79. */
  80. private $imgInstitucionName;
  81. /**
  82. * @ORM\Column(type="integer", nullable=true)
  83. *
  84. * @var int|null
  85. */
  86. private $imgInstitucionSize;
  87. /**
  88. * @ORM\ManyToOne(targetEntity="App\Core\Entity\Color")
  89. * @ORM\JoinColumn(nullable=false)
  90. */
  91. private $color;
  92. /**
  93. * @ORM\OneToMany(targetEntity=Campus::class, mappedBy="institucion")
  94. */
  95. private $campuses;
  96. /**
  97. * @ORM\OneToMany(targetEntity=InvitacionInstitucion::class, mappedBy="institucion")
  98. */
  99. private $invitacionInstitucions;
  100. public function __construct()
  101. {
  102. $this->directoresInstitucion = new ArrayCollection();
  103. $this->campuses = new ArrayCollection();
  104. $this->invitacionInstitucions = new ArrayCollection();
  105. }
  106. public function getId(): ?int
  107. {
  108. return $this->id;
  109. }
  110. public function getNombre(): ?string
  111. {
  112. return $this->nombre;
  113. }
  114. public function setNombre(string $nombre): self
  115. {
  116. $this->nombre = $nombre;
  117. return $this;
  118. }
  119. public function getSobreNosotros(): ?string
  120. {
  121. return $this->sobreNosotros;
  122. }
  123. public function setSobreNosotros(string $sobreNosotros): self
  124. {
  125. $this->sobreNosotros = $sobreNosotros;
  126. return $this;
  127. }
  128. public function getPaginaWeb(): ?string
  129. {
  130. return $this->paginaWeb;
  131. }
  132. public function setPaginaWeb(?string $paginaWeb): self
  133. {
  134. $this->paginaWeb = $paginaWeb;
  135. return $this;
  136. }
  137. /**
  138. * @return Collection|DirectorInstitucion[]
  139. */
  140. public function getDirectoresInstitucion(): Collection
  141. {
  142. return $this->directoresInstitucion;
  143. }
  144. public function addDirectoresInstitucion(DirectorInstitucion $directoresInstitucion): self
  145. {
  146. if (!$this->directoresInstitucion->contains($directoresInstitucion)) {
  147. $this->directoresInstitucion[] = $directoresInstitucion;
  148. $directoresInstitucion->setInstitucion($this);
  149. }
  150. return $this;
  151. }
  152. public function removeDirectoresInstitucion(DirectorInstitucion $directoresInstitucion): self
  153. {
  154. if ($this->directoresInstitucion->removeElement($directoresInstitucion)) {
  155. // set the owning side to null (unless already changed)
  156. if ($directoresInstitucion->getInstitucion() === $this) {
  157. $directoresInstitucion->setInstitucion(null);
  158. }
  159. }
  160. return $this;
  161. }
  162. public function getEstado(): ?int
  163. {
  164. return $this->estado;
  165. }
  166. public function setEstado(int $estado): self
  167. {
  168. $this->estado = $estado;
  169. return $this;
  170. }
  171. /**
  172. * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  173. * of 'UploadedFile' is injected into this setter to trigger the update. If this
  174. * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  175. * must be able to accept an instance of 'File' as the bundle will inject one here
  176. * during Doctrine hydration.
  177. *
  178. * @param File|UploadedFile|null $uploadedFile
  179. */
  180. public function setImgPortada(?File $uploadedFile = null): void
  181. {
  182. $this->imgPortada = $uploadedFile;
  183. if (null !== $uploadedFile) {
  184. // It is required that at least one field changes if you are using doctrine
  185. // otherwise the event listeners won't be called and the file is lost
  186. $this->setImgPortadaSize($uploadedFile->getSize());
  187. }
  188. }
  189. public function getImgPortada(): ?File
  190. {
  191. return $this->imgPortada;
  192. }
  193. public function setImgPortadaName(?string $imgPortadaName): void
  194. {
  195. $this->imgPortadaName = $imgPortadaName;
  196. }
  197. public function getImgPortadaName(): ?string
  198. {
  199. return $this->imgPortadaName;
  200. }
  201. public function setImgPortadaSize(?int $imgPortadaSize): void
  202. {
  203. $this->imgPortadaSize = $imgPortadaSize;
  204. }
  205. public function getImgPortadaSize(): ?int
  206. {
  207. return $this->imgPortadaSize;
  208. }
  209. /**
  210. * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  211. * of 'UploadedFile' is injected into this setter to trigger the update. If this
  212. * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  213. * must be able to accept an instance of 'File' as the bundle will inject one here
  214. * during Doctrine hydration.
  215. *
  216. * @param File|UploadedFile|null $uploadedFile
  217. */
  218. public function setImgInstitucion(?File $uploadedFile = null): void
  219. {
  220. $this->imgInstitucion = $uploadedFile;
  221. if (null !== $uploadedFile) {
  222. // It is required that at least one field changes if you are using doctrine
  223. // otherwise the event listeners won't be called and the file is lost
  224. $this->setImgInstitucionSize($uploadedFile->getSize());
  225. }
  226. }
  227. public function getImgInstitucion(): ?File
  228. {
  229. return $this->imgInstitucion;
  230. }
  231. public function setImgInstitucionName(?string $imgInstitucionName): void
  232. {
  233. $this->imgInstitucionName = $imgInstitucionName;
  234. }
  235. public function getImgInstitucionName(): ?string
  236. {
  237. return $this->imgInstitucionName;
  238. }
  239. public function setImgInstitucionSize(?int $imgInstitucionSize): void
  240. {
  241. $this->imgInstitucionSize = $imgInstitucionSize;
  242. }
  243. public function getImgInstitucionSize(): ?int
  244. {
  245. return $this->imgInstitucionSize;
  246. }
  247. public function getColor(): ?Color
  248. {
  249. return $this->color;
  250. }
  251. public function setColor(Color $color): self
  252. {
  253. $this->color = $color;
  254. return $this;
  255. }
  256. /**
  257. * @return Collection|Campus[]
  258. */
  259. public function getCampuses(): Collection
  260. {
  261. return $this->campuses;
  262. }
  263. public function addCampus(Campus $campus): self
  264. {
  265. if (!$this->campuses->contains($campus)) {
  266. $this->campuses[] = $campus;
  267. $campus->setInstitucion($this);
  268. }
  269. return $this;
  270. }
  271. public function removeCampus(Campus $campus): self
  272. {
  273. if ($this->campuses->removeElement($campus)) {
  274. // set the owning side to null (unless already changed)
  275. if ($campus->getInstitucion() === $this) {
  276. $campus->setInstitucion(null);
  277. }
  278. }
  279. return $this;
  280. }
  281. /**
  282. * @return Collection<int, InvitacionInstitucion>
  283. */
  284. public function getInvitacionInstitucions(): Collection
  285. {
  286. return $this->invitacionInstitucions;
  287. }
  288. public function addInvitacionInstitucion(InvitacionInstitucion $invitacionInstitucion): self
  289. {
  290. if (!$this->invitacionInstitucions->contains($invitacionInstitucion)) {
  291. $this->invitacionInstitucions[] = $invitacionInstitucion;
  292. $invitacionInstitucion->setInstitucion($this);
  293. }
  294. return $this;
  295. }
  296. public function removeInvitacionInstitucion(InvitacionInstitucion $invitacionInstitucion): self
  297. {
  298. if ($this->invitacionInstitucions->removeElement($invitacionInstitucion)) {
  299. // set the owning side to null (unless already changed)
  300. if ($invitacionInstitucion->getInstitucion() === $this) {
  301. $invitacionInstitucion->setInstitucion(null);
  302. }
  303. }
  304. return $this;
  305. }
  306. }