src/Entity/App/RedSocial.php line 18

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