src/Domain/Entity/Tramite.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Domain\Entity;
  3. use App\Domain\Enum\EstadoTramiteEnum;
  4. use App\Domain\Interfaces\MetadataInterface;
  5. use App\Shared\Domain\ApplicationCore\Interfaces\EntityInterface;
  6. use DateTimeInterface;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\DBAL\Types\Types;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Symfony\Component\Uid\Uuid;
  12. class Tramite implements EntityInterfaceMetadataInterface
  13. {
  14.     private ?string $key null;
  15.     private ?string $nombre null;
  16.     private ?string $procedimiento null;
  17.     private ?string $descripcion null;
  18.     private ?DateTimeInterface $createdAt null;
  19.     private ?DateTimeInterface $updatedAt null;
  20.     private $form null;
  21.     private ?Uuid $id null;
  22.     private ?string $translationDomain null;
  23.     private ?Expediente $expediente null;
  24.     private ?EstadoTramite $estadoTramite null;
  25.     private ?MetadataTramite $metadata null;
  26.     private Collection $responsables;
  27.     private Collection $alarmas;
  28.     private ?\DateTimeInterface $deletedAt null;
  29.     private $schema null;
  30.     private ?string $js null;
  31.     private ?string $css null;
  32.     private ?string $translations null;
  33.     public function __construct()
  34.     {
  35.         $this->responsables = new ArrayCollection();
  36.         $this->alarmas = new ArrayCollection();
  37.     }
  38.     /**
  39.      * FIX-260601-008 — devuelve string plano para evitar que Doctrine/Sonata
  40.      * confunda render HTML con identidad del entity (entityNotManaged en flush).
  41.      * Para el render visual del header usar {@see renderHeaderHTML()}.
  42.      */
  43.     public function __toString(): string
  44.     {
  45.         return $this->getNombre() ?? $this->getKey() ?? '';
  46.     }
  47.     /**
  48.      * FIX-260601-008 — HTML del header del tramite (estado + fase + fecha).
  49.      * Mantiene el render visual previo, separado del identificador __toString.
  50.      */
  51.     public function renderHeaderHTML(): string
  52.     {
  53.         $title $this->getNombre() ?? $this->getKey() ?? '';
  54.         return '<div id="estado">Estado <span style="background-color: '.$this->getEstadoTramite()?->getColor().'; border-radius: 50%; width: 20px; height: 20px; display: block;" title="'.EstadoTramiteEnum::getEstado($this->getEstadoTramite()?->getKey()).'"></span>'
  55.             .'</div><div id="tramite">Fase: '.$title
  56.             .'</div><div id="fecha">Fecha '.$this->getUpdatedAt()?->format('d/m/Y')
  57.             .'</div>';
  58.     }
  59.     public function getMetadata(): ?MetadataTramite
  60.     {
  61.         return $this->metadata;
  62.     }
  63.     public function setMetadata(?MetadataInterface $metadata): static
  64.     {
  65.         $this->metadata $metadata;
  66.         return $this;
  67.     }
  68.     public function getKey(): ?string
  69.     {
  70.         return $this->key;
  71.     }
  72.     public function setKey(string $key): static
  73.     {
  74.         $this->key $key;
  75.         return $this;
  76.     }
  77.     public function getCreatedAt(): ?DateTimeInterface
  78.     {
  79.         return $this->createdAt;
  80.     }
  81.     public function setCreatedAt(DateTimeInterface $createdAt): static
  82.     {
  83.         $this->createdAt $createdAt;
  84.         return $this;
  85.     }
  86.     public function getUpdatedAt(): ?DateTimeInterface
  87.     {
  88.         return $this->updatedAt;
  89.     }
  90.     public function setUpdatedAt(DateTimeInterface $updatedAt): static
  91.     {
  92.         $this->updatedAt $updatedAt;
  93.         return $this;
  94.     }
  95.     public function getId(): ?Uuid
  96.     {
  97.         return $this->id;
  98.     }
  99.     public function getExpediente(): ?Expediente
  100.     {
  101.         return $this->expediente;
  102.     }
  103.     public function setExpediente(?Expediente $expediente): static
  104.     {
  105.         $this->expediente $expediente;
  106.         return $this;
  107.     }
  108.     public function getEstado(): ?Estado
  109.     {
  110.         return $this->estadoTramite;
  111.     }
  112.     public function getEstadoTramite(): ?EstadoTramite
  113.     {
  114.         return $this->estadoTramite;
  115.     }
  116.     public function setEstadoTramite(?EstadoTramite $estadoTramite): static
  117.     {
  118.         $this->estadoTramite $estadoTramite;
  119.         return $this;
  120.     }
  121.     public function getSchema(): ?string
  122.     {
  123.         return $this->schema?$this->schema:$this->getMetadata()?->getSchema();
  124.     }
  125.     public function setSchema(?string $schema): static
  126.     {
  127.         $this->schema $schema;
  128.         return $this;
  129.     }
  130.     public function getForm(): ?string
  131.     {
  132.         return $this->form;
  133.     }
  134.     public function setForm(?string $form): static
  135.     {
  136.         $this->form $form;
  137.         return $this;
  138.     }
  139.     public function getNombre(): ?string
  140.     {
  141.         return $this->nombre;
  142.     }
  143.     public function setNombre(?string $nombre): static
  144.     {
  145.         $this->nombre $nombre;
  146.         return $this;
  147.     }
  148.     public function getDescripcion(): ?string
  149.     {
  150.         return $this->descripcion;
  151.     }
  152.     public function setDescripcion(?string $descripcion): static
  153.     {
  154.         $this->descripcion $descripcion;
  155.         return $this;
  156.     }
  157.     /**
  158.      * @return Collection<int, SonataUserUser>
  159.      */
  160.     public function getResponsables(): Collection
  161.     {
  162.         return $this->responsables;
  163.     }
  164.     public function addResponsable(SonataUserUser $responsable): static
  165.     {
  166.         if (!$this->responsables->contains($responsable)) {
  167.             $this->responsables->add($responsable);
  168.         }
  169.         return $this;
  170.     }
  171.     public function removeResponsable(SonataUserUser $responsable): static
  172.     {
  173.         $this->responsables->removeElement($responsable);
  174.         return $this;
  175.     }
  176.     public function getCss(): ?string
  177.     {
  178.         return $this->css;
  179.     }
  180.     public function setCss(?string $css): static
  181.     {
  182.         $this->css $css;
  183.         return $this;
  184.     }
  185.     public function getJs(): ?string
  186.     {
  187.         return $this->js;
  188.     }
  189.     public function setJs(?string $js): static
  190.     {
  191.         $this->js $js;
  192.         return $this;
  193.     }
  194.     public function getTranslations(): ?string
  195.     {
  196.         return $this->translations;
  197.     }
  198.     public function setTranslations(?string $translations): static
  199.     {
  200.         $this->translations $translations;
  201.         return $this;
  202.     }
  203.     public function getTranslationDomain(): ?string
  204.     {
  205.         return $this->translationDomain;
  206.     }
  207.     public function setTranslationDomain(?string $translationDomain): static
  208.     {
  209.         $this->translationDomain $translationDomain;
  210.         return $this;
  211.     }
  212.     /**
  213.      * @return Collection<int, Alarma>
  214.      */
  215.     public function getAlarmas(): Collection
  216.     {
  217.         return $this->alarmas;
  218.     }
  219.     public function addAlarma(Alarma $alarma): static
  220.     {
  221.         if (!$this->alarmas->contains($alarma)) {
  222.             $this->alarmas->add($alarma);
  223.             $alarma->setTramite($this);
  224.         }
  225.         return $this;
  226.     }
  227.     public function removeAlarma(Alarma $alarma): static
  228.     {
  229.         if ($this->alarmas->removeElement($alarma)) {
  230.             // set the owning side to null (unless already changed)
  231.             if ($alarma->getTramite() === $this) {
  232.                 $alarma->setTramite(null);
  233.             }
  234.         }
  235.         return $this;
  236.     }
  237.     public function getDeletedAt(): ?\DateTimeInterface
  238.     {
  239.         return $this->deletedAt;
  240.     }
  241.     public function setDeletedAt(?\DateTimeInterface $deletedAt): static
  242.     {
  243.         $this->deletedAt $deletedAt;
  244.         return $this;
  245.     }
  246.     public function getProcedimiento(): ?string
  247.     {
  248.         return $this->procedimiento;
  249.     }
  250.     public function setProcedimiento(?string $procedimiento): static
  251.     {
  252.         $this->procedimiento $procedimiento;
  253.         return $this;
  254.     }
  255. }