src/Entity/App/Parameter.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Entity\App;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Gedmo\Timestampable\Traits\TimestampableEntity;
  5. use JsonSerializable;
  6. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. /**
  9.  * Parameter
  10.  *
  11.  * @ORM\Table(name="parameter", indexes={@ORM\Index(name="IDX_NAME", columns={"name"})})
  12.  * @ORM\Entity(repositoryClass="App\Repository\App\ParameterRepository")
  13.  *
  14.  * @UniqueEntity(
  15.  *     fields="name",
  16.  *     errorPath="name",
  17.  *     message="El nombre ya existe"
  18.  * )
  19.  */
  20. class Parameter implements JsonSerializable
  21. {
  22.     const TYPE_SHORT_TEXT 'input';
  23.     const TYPE_BOOL 'toggle';
  24.     /**
  25.      * @var integer|null
  26.      *
  27.      * @ORM\Column(name="id", type="integer")
  28.      * @ORM\Id
  29.      * @ORM\GeneratedValue
  30.      */
  31.     private $id;
  32.     /**
  33.      * @var string|null
  34.      *
  35.      * @ORM\Column(name="type", type="string", length=255, nullable=true)
  36.      * @Assert\Length(
  37.      *      max = 255,
  38.      *      maxMessage = "La cantidad maxima es {{ limit }} caracteres"
  39.      * )
  40.      */
  41.     private $type;
  42.     /**
  43.      * @var string
  44.      *
  45.      * @ORM\Column(name="name", type="string", length=255, unique=true)
  46.      * @Assert\NotBlank(message="Name requerido")
  47.      * @Assert\Length(
  48.      *      max = 255,
  49.      *      maxMessage = "La cantidad maxima es {{ limit }} caracteres"
  50.      * )
  51.      */
  52.     private $name;
  53.     /**
  54.      * @var string|null
  55.      *
  56.      * @ORM\Column(name="value", type="text", nullable=true)
  57.      */
  58.     private $value;
  59.     /**
  60.      * @var string|null
  61.      *
  62.      * @ORM\Column(name="description", type="text", nullable=true)
  63.      * @Assert\Length(
  64.      *      max = 1000,
  65.      *      maxMessage = "La cantidad maxima es {{ limit }} caracteres"
  66.      * )
  67.      */
  68.     private $description;
  69.     /**
  70.      * @var string|null
  71.      *
  72.      * @ORM\Column(name="help", type="string", length=255, nullable=true)
  73.      * @Assert\Length(
  74.      *      max = 255,
  75.      *      maxMessage = "La cantidad maxima es {{ limit }} caracteres"
  76.      * )
  77.      */
  78.     private $help;
  79.     use TimestampableEntity;
  80.     /**
  81.      * @return int|null
  82.      */
  83.     public function getId(): ?int
  84.     {
  85.         return $this->id;
  86.     }
  87.     /**
  88.      * @return string|null
  89.      */
  90.     public function getType(): ?string
  91.     {
  92.         return $this->type;
  93.     }
  94.     /**
  95.      * @param string|null $type
  96.      */
  97.     public function setType(?string $type): void
  98.     {
  99.         $this->type $type;
  100.     }
  101.     /**
  102.      * @return string
  103.      */
  104.     public function getName(): string
  105.     {
  106.         return $this->name;
  107.     }
  108.     /**
  109.      * @param string $name
  110.      */
  111.     public function setName(string $name): void
  112.     {
  113.         $this->name $name;
  114.     }
  115.     /**
  116.      * @return string|null
  117.      */
  118.     public function getValue(): ?string
  119.     {
  120.         return $this->value;
  121.     }
  122.     /**
  123.      * @param string|null $value
  124.      */
  125.     public function setValue(?string $value): void
  126.     {
  127.         $this->value $value;
  128.     }
  129.     /**
  130.      * @return string|null
  131.      */
  132.     public function getDescription(): ?string
  133.     {
  134.         return $this->description;
  135.     }
  136.     /**
  137.      * @param string|null $description
  138.      */
  139.     public function setDescription(?string $description): void
  140.     {
  141.         $this->description $description;
  142.     }
  143.     /**
  144.      * @return string|null
  145.      */
  146.     public function getHelp(): ?string
  147.     {
  148.         return $this->help;
  149.     }
  150.     /**
  151.      * @param string|null $help
  152.      */
  153.     public function setHelp(?string $help): void
  154.     {
  155.         $this->help $help;
  156.     }
  157.     public function __toString()
  158.     {
  159.         return $this->getName() . ': ' $this->getValue();
  160.     }
  161.     /**
  162.      * Specify data which should be serialized to JSON
  163.      * @link http://php.net/manual/en/jsonserializable.jsonserialize.php
  164.      * @return mixed data which can be serialized by <b>json_encode</b>,
  165.      * which is a value of any type other than a resource.
  166.      * @since 5.4.0
  167.      */
  168.     public function jsonSerialize()
  169.     {
  170.         return array(
  171.             $this->getName() => $this->getValue()
  172.         );
  173.     }
  174. }