src/Entity/App/Tramite.php line 32

Open in your IDE?
  1. <?php
  2. namespace App\Entity\App;
  3. use App\Utils\CommonFunctions;
  4. use App\Utils\Traits\ActivoTrait;
  5. use App\Utils\Traits\PosicionTrait;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Gedmo\Mapping\Annotation as Gedmo;
  10. use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity;
  11. use Gedmo\Timestampable\Traits\TimestampableEntity;
  12. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  13. use Symfony\Component\Validator\Constraints as Assert;
  14. /**
  15.  * Tramite
  16.  *
  17.  * @ORM\Table(name="tramite", indexes={@ORM\Index(name="IDX_NOMBRE", columns={"nombre"})})
  18.  * @ORM\Entity(repositoryClass="App\Repository\App\TramiteRepository")
  19.  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
  20.  * @UniqueEntity(
  21.  *       fields={"nombre"},
  22.  *       message="El nombre ya está en uso. Por favor, elige otro."
  23.  *   )
  24.  * @UniqueEntity(
  25.  *        fields={"link"},
  26.  *        message="La url ya se encuentra asignada a un tramite existente. Por favor, elige otro."
  27.  *    )
  28.  */
  29. class Tramite
  30. {
  31.     /**
  32.      * @var integer|null
  33.      *
  34.      * @ORM\Column(name="id", type="integer")
  35.      * @ORM\Id
  36.      * @ORM\GeneratedValue
  37.      */
  38.     private $id;
  39.     /**
  40.      * @var string|null
  41.      *
  42.      * @ORM\Column(name="nombre", type="string", length=255)
  43.      * @Assert\NotBlank(message="El valor es requerido")
  44.      */
  45.     private $nombre;
  46.     /**
  47.      * @var string|null
  48.      *
  49.      * @ORM\Column(name="codigo", type="string", length=255, nullable=true)
  50.      * @Assert\Length(
  51.      *      max = 255,
  52.      *      maxMessage = "La cantidad maxima es {{ limit }} caracteres"
  53.      * )
  54.      */
  55.     private $codigo;
  56.     /**
  57.      * @var string|null
  58.      *
  59.      * @ORM\Column(name="descripcion", type="text", nullable=true)
  60.      * @Assert\NotBlank(message="El valor es requerido")
  61.      */
  62.     private $descripcion;
  63.     /**
  64.      * @var string|null
  65.      *
  66.      * @ORM\Column(name="link", type="text", nullable=true)
  67.      * @Assert\Length(
  68.      *      max = 1000,
  69.      *      maxMessage = "La cantidad maxima es {{ limit }} caracteres"
  70.      * )
  71.      * @Assert\NotBlank(message="El valor es requerido")
  72.      */
  73.     private $link;
  74.     /**
  75.      * @var string|null
  76.      *
  77.      * @ORM\Column(name="path_interno", type="text", nullable=true)
  78.      * @Assert\Length(
  79.      *      max = 1000,
  80.      *      maxMessage = "La cantidad maxima es {{ limit }} caracteres"
  81.      * )
  82.      */
  83.     private $pathInterno;
  84.     /**
  85.      * @var boolean
  86.      *
  87.      * @ORM\Column(name="es_path_interno", type="boolean")
  88.      * @Assert\Type(
  89.      *     type="bool",
  90.      *     message="El valor debe ser un bool"
  91.      * )
  92.      */
  93.     private $esPathInterno;
  94.     /**
  95.      * @var boolean
  96.      *
  97.      * @ORM\Column(name="tiene_ficha", type="boolean")
  98.      * @Assert\Type(
  99.      *     type="bool",
  100.      *     message="El valor debe ser un bool"
  101.      * )
  102.      */
  103.     private $tieneFicha;
  104.     /**
  105.      * @ORM\ManyToMany(targetEntity="App\Entity\App\Grupo", inversedBy="tramites")
  106.      * @ORM\JoinTable(name="tramites_grupos")
  107.      */
  108.     private $grupos;
  109.     /**
  110.      * @ORM\ManyToMany(targetEntity="App\Entity\App\Categoria", inversedBy="tramites")
  111.      * @ORM\JoinTable(name="tramites_categorias")
  112.      */
  113.     private $categorias;
  114.     /**
  115.      * @var boolean
  116.      *
  117.      * @ORM\Column(name="destacado", type="boolean")
  118.      * @Assert\Type(
  119.      *     type="bool",
  120.      *     message="El valor debe ser un bool"
  121.      * )
  122.      */
  123.     private $destacado false;
  124.     /**
  125.      * @var integer|null
  126.      *
  127.      * @ORM\Column(name="posicion_destacado", type="integer", nullable=true)
  128.      */
  129.     private $posicionDestacado null;
  130.     /**
  131.      * @var integer|null
  132.      *
  133.      * @ORM\Column(name="id_drupal", type="integer", nullable=true)
  134.      */
  135.     private $idDrupal;
  136.     /**
  137.      * @var string|null
  138.      *
  139.      * @ORM\Column(name="url_tad", type="string", length=1000, nullable=true)
  140.      * @Assert\Length(
  141.      *      max = 1000,
  142.      *      maxMessage = "La cantidad maxima es {{ limit }} caracteres"
  143.      * )
  144.      */
  145.     private $urlTad;
  146.     /**
  147.      * @var boolean | null
  148.      * @ORM\Column(name="modalidad_online", type="boolean", nullable=true)
  149.      */
  150.     private $modalidadOnline;
  151.     /**
  152.      * @var boolean | null
  153.      * @ORM\Column(name="modalidad_presencial", type="boolean", nullable=true)
  154.      */
  155.     private $modalidadPresencial;
  156.     /**
  157.      * @var boolean | null
  158.      * @ORM\Column(name="pago", type="boolean", nullable=true)
  159.     */
  160.     private $pago;
  161.     use ActivoTrait;
  162.     use PosicionTrait;
  163.     use TimestampableEntity;
  164.     use SoftDeleteableEntity;
  165.     public function __construct()
  166.     {
  167.         $this->categorias = new ArrayCollection();
  168.         $this->grupos = new ArrayCollection();
  169.     }
  170.     /**
  171.      * @return int|null
  172.      */
  173.     public function getId(): ?int
  174.     {
  175.         return $this->id;
  176.     }
  177.     /**
  178.      * @return string|null
  179.      */
  180.     public function getNombre(): ?string
  181.     {
  182.         return $this->nombre;
  183.     }
  184.     /**
  185.      * @param string|null $nombre
  186.      */
  187.     public function setNombre(?string $nombre): void
  188.     {
  189.         $this->nombre $nombre;
  190.     }
  191.     /**
  192.      * @return string|null
  193.      */
  194.     public function getCodigo(): ?string
  195.     {
  196.         return $this->codigo;
  197.     }
  198.     /**
  199.      * @param string|null $codigo
  200.      */
  201.     public function setCodigo(?string $codigo): void
  202.     {
  203.         $this->codigo $codigo;
  204.     }
  205.     /**
  206.      * @return string|null
  207.      */
  208.     public function getDescripcion(): ?string
  209.     {
  210.         return $this->descripcion;
  211.     }
  212.     /**
  213.      * @param string|null $descripcion
  214.      */
  215.     public function setDescripcion(?string $descripcion): void
  216.     {
  217.         $this->descripcion $descripcion;
  218.     }
  219.     /**
  220.      * @return string|null
  221.      */
  222.     public function getLink(): ?string
  223.     {
  224.         return $this->link;
  225.     }
  226.     /**
  227.      * @param string|null $link
  228.      */
  229.     public function setLink(?string $link): void
  230.     {
  231.         $this->link $link;
  232.     }
  233.     public function getValidLink()
  234.     {
  235.         $link $this->getLink();
  236.         if ($this->isEsPathInterno() == && $this->getPathInterno()) {
  237.             $link implode('/', [CommonFunctions::getParameterUrl('FRONT_URL'), CommonFunctions::removeFirstSlash($this->getPathInterno())]);
  238.         }
  239.         return $link;
  240.     }
  241.     public function __toString()
  242.     {
  243.         return $this->getNombre() ?: 'Nuevo trámite';
  244.     }
  245.     /**
  246.      * @return string|null
  247.      */
  248.     public function getPathInterno(): ?string
  249.     {
  250.         return $this->pathInterno;
  251.     }
  252.     /**
  253.      * @param string|null $pathInterno
  254.      */
  255.     public function setPathInterno(?string $pathInterno): void
  256.     {
  257.         $this->pathInterno $pathInterno;
  258.     }
  259.     /**
  260.      * @return bool|null
  261.      */
  262.     public function isEsPathInterno(): ?bool
  263.     {
  264.         return $this->esPathInterno;
  265.     }
  266.     /**
  267.      * @param bool $esPathInterno
  268.      */
  269.     public function setEsPathInterno(bool $esPathInterno): void
  270.     {
  271.         $this->esPathInterno $esPathInterno;
  272.     }
  273.     /**
  274.      * @return bool
  275.      */
  276.     public function isTieneFicha(): bool
  277.     {
  278.         return $this->tieneFicha;
  279.     }
  280.     /**
  281.      * @param bool $tieneFicha
  282.      */
  283.     public function setTieneFicha(bool $tieneFicha): void
  284.     {
  285.         $this->tieneFicha $tieneFicha;
  286.     }
  287.     public function getDirectoryFile()
  288.     {
  289.         $class CommonFunctions::getClassMethod(__CLASS__);
  290.         $class CommonFunctions::camelCaseToSnakeCase($class'-');
  291.         $dir CommonFunctions::getParameter('BASE_PATH_ARCHIVOS');
  292.         return CommonFunctions::getPathOrURLWithSlash($dir) . $class;
  293.     }
  294.     public function getAbsolutePath($name)
  295.     {
  296.         return CommonFunctions::getAbsolutePath($this->getDirectoryFile(), $name);
  297.     }
  298.     public function getCategorias(): Collection
  299.     {
  300.         return $this->categorias;
  301.     }
  302.     public function addCategoria(Categoria $categoria): self
  303.     {
  304.         if (!$this->categorias->contains($categoria)) {
  305.             $this->categorias[] = $categoria;
  306.         }
  307.         return $this;
  308.     }
  309.     public function removeCategoria(Categoria $categoria): self
  310.     {
  311.         $this->categorias->removeElement($categoria);
  312.         return $this;
  313.     }
  314.     public function getGrupos(): Collection
  315.     {
  316.         return $this->grupos;
  317.     }
  318.     public function addGrupos(Grupo $grupo)
  319.     {
  320.         if (!$this->grupos->contains($grupo)) {
  321.             $this->grupos[] = $grupo;
  322.         }
  323.         return $this;
  324.     }
  325.     public function removeGrupo(Grupo $grupo): self
  326.     {
  327.         $this->grupos->removeElement($grupo);
  328.         return $this;
  329.     }
  330.     public function isDestacado(): bool
  331.     {
  332.         return $this->destacado;
  333.     }
  334.     public function setDestacado(bool $destacado): void
  335.     {
  336.         $this->destacado $destacado;
  337.     }
  338.     public function getPosicionDestacado(): ?int
  339.     {
  340.         return $this->posicionDestacado;
  341.     }
  342.     public function setPosicionDestacado(?int $posicionDestacado): void
  343.     {
  344.         $this->posicionDestacado $posicionDestacado;
  345.     }
  346.     /**
  347.      * @return int|null
  348.      */
  349.     public function getIdDrupal(): ?int
  350.     {
  351.         return $this->idDrupal;
  352.     }
  353.     /**
  354.      * @param int|null $idDrupal
  355.      */
  356.     public function setIdDrupal(?int $idDrupal): void
  357.     {
  358.         $this->idDrupal $idDrupal;
  359.     }
  360.     /**
  361.      * @return string|null
  362.      */
  363.     public function getUrlTad(): ?string
  364.     {
  365.         return $this->urlTad;
  366.     }
  367.     /**
  368.      * @param string|null $urlTad
  369.      */
  370.     public function setUrlTad(?string $urlTad): void
  371.     {
  372.         $this->urlTad $urlTad;
  373.     }
  374.     public function getModalidadOnline(): ?bool
  375.     {
  376.         return $this->modalidadOnline;
  377.     }
  378.     public function setModalidadOnline(?bool $modalidadOnline): void
  379.     {
  380.         $this->modalidadOnline $modalidadOnline;
  381.     }
  382.     public function getModalidadPresencial(): ?bool
  383.     {
  384.         return $this->modalidadPresencial;
  385.     }
  386.     public function setModalidadPresencial(?bool $modalidadPresencial): void
  387.     {
  388.         $this->modalidadPresencial $modalidadPresencial;
  389.     }
  390.     public function getPago(): ?bool
  391.     {
  392.         return $this->pago;
  393.     }
  394.     public function setPago(?bool $pago): void
  395.     {
  396.         $this->pago $pago;
  397.     }
  398. }