src/Entity/App/AnimalesRedSocial.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity\App;
  3. use App\Utils\Constants;
  4. use App\Utils\Traits\ActivoTrait;
  5. use App\Utils\Traits\PosicionTrait;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Timestampable\Traits\TimestampableEntity;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. /**
  10.  * @ORM\Table(name="animales_red_social", indexes={@ORM\Index(name="IDX_LINK", columns={"link"})})
  11.  * @ORM\Entity(repositoryClass="App\Repository\App\AnimalesRedSocialRepository")
  12.  */
  13. class AnimalesRedSocial
  14. {
  15.     /**
  16.      * @var integer|null
  17.      *
  18.      * @ORM\Column(name="id", type="integer")
  19.      * @ORM\Id
  20.      * @ORM\GeneratedValue
  21.      */
  22.     private $id;
  23.     /**
  24.      * @var string|null
  25.      *
  26.      * @ORM\Column(name="link", type="string", length=255)
  27.      * @Assert\NotBlank(message="El valor es requerido")
  28.      * @Assert\Regex(
  29.      *     pattern="/^(http[s]?:\/\/){0,1}(www\.){0,1}[a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,5}[\.]{0,1}[\/]?/",
  30.      *     message="Ingrese un link correcto"
  31.      * )
  32.      * @Assert\Length(
  33.      *      max = 255,
  34.      *      maxMessage = "La cantidad maxima es {{ limit }} caracteres"
  35.      * )
  36.      */
  37.     private $link;
  38.     /**
  39.      * @var string|null
  40.      *
  41.      * @ORM\Column(name="icono", type="string", length=255)
  42.      * @Assert\NotBlank(message="El valor es requerido")
  43.      * @Assert\Length(
  44.      *      max = 255,
  45.      *      maxMessage = "La cantidad maxima es {{ limit }} caracteres"
  46.      * )
  47.      */
  48.     private $icono;
  49.     use ActivoTrait;
  50.     use PosicionTrait;
  51.     use TimestampableEntity;
  52.     /**
  53.      * @return int|null
  54.      */
  55.     public function getId(): ?int
  56.     {
  57.         return $this->id;
  58.     }
  59.     /**
  60.      * @return string|null
  61.      */
  62.     public function getLink(): ?string
  63.     {
  64.         return $this->link;
  65.     }
  66.     /**
  67.      * @param string|null $link
  68.      */
  69.     public function setLink(?string $link): void
  70.     {
  71.         $this->link $link;
  72.     }
  73.     /**
  74.      * @return string|null
  75.      */
  76.     public function getIcono(): ?string
  77.     {
  78.         return $this->icono;
  79.     }
  80.     /**
  81.      * @param string|null $icono
  82.      */
  83.     public function setIcono(?string $icono): void
  84.     {
  85.         $this->icono $icono;
  86.     }
  87.     public function getNombre()
  88.     {
  89.         return array_flip(Constants::REDES_SOCIALES)[$this->getIcono()];
  90.     }
  91.     public function __toString()
  92.     {
  93.         return $this->getLink();
  94.     }
  95. }