src/Entity/AccionAbstract.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Enum\TipoAccionEnum;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. use Symfony\Component\Uid\Uuid;
  7. /**
  8. * @ORM\Entity(repositoryClass="App\Repository\AccionAbstractRepository")
  9. * @ORM\Table(name="accion_abstract", schema="perseo")
  10. * @ORM\InheritanceType("SINGLE_TABLE")
  11. * @ORM\DiscriminatorColumn(name="type", type="string")
  12. * @ORM\DiscriminatorMap({
  13. * "estado":"App\Entity\AccionEstado",
  14. * "ubicacion":"App\Entity\AccionUbicacion",
  15. * "mejora":"App\Entity\AccionMejora",
  16. * "competencia":"App\Entity\AccionCompetencia",
  17. * "servicio":"App\Entity\AccionServicio",
  18. * "check":"App\Entity\AccionCheck",
  19. * "anuncio":"App\Entity\AccionAnuncio"
  20. * })
  21. * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
  22. */
  23. Abstract class AccionAbstract
  24. {
  25. /**
  26. * @ORM\Id
  27. * @ORM\Column(type="uuid", unique=true)
  28. * @ORM\GeneratedValue(strategy="CUSTOM")
  29. * @ORM\CustomIdGenerator(class="doctrine.uuid_generator")
  30. */
  31. private $id;
  32. /**
  33. * @ORM\Column(type="string", nullable=true)
  34. */
  35. private $descripcion;
  36. /**
  37. * @ORM\Column(type="text", nullable=true, name="descripcion_detallada")
  38. */
  39. private $descripcionDetallada;
  40. /**
  41. * @ORM\Column(type="datetime", nullable=true)
  42. */
  43. private $fecha;
  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":"2022-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":"2022-01-01 00:00:00"})
  55. * @Gedmo\Timestampable(on="create")
  56. */
  57. private $createdAt;
  58. /**
  59. * @ORM\ManyToOne(targetEntity="App\Entity\Promocion", inversedBy="acciones")
  60. * @ORM\JoinColumn(name="promocion_id", referencedColumnName="id")
  61. */
  62. private $promocion;
  63. public function getId(): ?Uuid
  64. {
  65. return $this->id;
  66. }
  67. public function getDescripcion(): ?string
  68. {
  69. return $this->descripcion;
  70. }
  71. public function setDescripcion(?string $descripcion): self
  72. {
  73. $this->descripcion = $descripcion;
  74. return $this;
  75. }
  76. public function getDescripcionDetallada(): ?string
  77. {
  78. return $this->descripcionDetallada;
  79. }
  80. public function setDescripcionDetallada(?string $descripcionDetallada): self
  81. {
  82. $this->descripcionDetallada = $descripcionDetallada;
  83. return $this;
  84. }
  85. public function getFecha(): ?\DateTimeInterface
  86. {
  87. return $this->fecha;
  88. }
  89. public function setFecha(?\DateTimeInterface $fecha): self
  90. {
  91. $this->fecha = $fecha;
  92. return $this;
  93. }
  94. public function getDeletedAt(): ?\DateTimeInterface
  95. {
  96. return $this->deletedAt;
  97. }
  98. public function setDeletedAt(?\DateTimeInterface $deletedAt): self
  99. {
  100. $this->deletedAt = $deletedAt;
  101. return $this;
  102. }
  103. public function getUpdatedAt(): ?\DateTimeInterface
  104. {
  105. return $this->updatedAt;
  106. }
  107. public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  108. {
  109. $this->updatedAt = $updatedAt;
  110. return $this;
  111. }
  112. public function getCreatedAt(): ?\DateTimeInterface
  113. {
  114. return $this->createdAt;
  115. }
  116. public function setCreatedAt(\DateTimeInterface $createdAt): self
  117. {
  118. $this->createdAt = $createdAt;
  119. return $this;
  120. }
  121. public function getPromocion(): ?Promocion
  122. {
  123. return $this->promocion;
  124. }
  125. public function setPromocion(?Promocion $promocion): self
  126. {
  127. $this->promocion = $promocion;
  128. return $this;
  129. }
  130. public function getTipoAccion(): string
  131. {
  132. $tipo = '---';
  133. switch (get_class($this))
  134. {
  135. case AccionAnuncio::class:
  136. $tipo = TipoAccionEnum::ACCION_ANUNCIO;
  137. break;
  138. case AccionCheck::class:
  139. $tipo = TipoAccionEnum::ACCION_CHECK;
  140. break;
  141. case AccionCompetencia::class:
  142. $tipo = TipoAccionEnum::ACCION_COMPETENCIA;
  143. break;
  144. case AccionEstado::class:
  145. $tipo = TipoAccionEnum::ACCION_ESTADO;
  146. break;
  147. case AccionMejora::class:
  148. $tipo = TipoAccionEnum::ACCION_MEJORA;
  149. break;
  150. case AccionServicio::class:
  151. $tipo = TipoAccionEnum::ACCION_SERVICIO;
  152. break;
  153. case AccionUbicacion::class:
  154. $tipo = TipoAccionEnum::ACCION_UBICACION;
  155. break;
  156. }
  157. return $tipo;
  158. }
  159. }