src/Entity/Locale.php line 27

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Serializer\Annotation\Groups;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. /**
  8.  * Locale.
  9.  *
  10.  * @ApiResource(
  11.  * itemOperations={
  12.  *      "get"={"method"="GET"},
  13.  *      "put"={"method"="PUT", "access_control"="is_granted('ROLE_ADMIN')"},
  14.  *      "delete"={"method"="DELETE", "access_control"="is_granted('ROLE_ADMIN')"}
  15.  * },
  16.  * collectionOperations = {
  17.  *  "get"={"method"="GET"},
  18.  *  "post"={"method"="POST","access_control"="is_granted('ROLE_ADMIN')"},
  19.  * },
  20.  * )
  21.  * @ORM\Table(name="locale")
  22.  * @ORM\Entity()
  23.  */
  24. class Locale
  25. {
  26.     /**
  27.      * @var int
  28.      *
  29.      * @ORM\Column(name="id", type="integer")
  30.      * @ORM\Id
  31.      * @ORM\GeneratedValue(strategy="AUTO")
  32.      * @Groups({"out"})
  33.      */
  34.     private $id;
  35.     /**
  36.      * @var string
  37.      *
  38.      * @Assert\NotBlank()
  39.      * @Assert\Length(
  40.      *      min = 1,
  41.      *      max = 7,
  42.      *      minMessage = "Locale code must be at least {{ limit }} characters long",
  43.      *      maxMessage = "Locale code cannot be longer than {{ limit }} characters"
  44.      * )
  45.      * @ORM\Column(name="code", type="string", length=7)
  46.      * @Groups({"out"})
  47.      */
  48.     private $code;
  49.     /**
  50.      * @var string
  51.      *
  52.      * @Assert\NotBlank()
  53.      * @Assert\Length(
  54.      *      min = 1,
  55.      *      max = 45,
  56.      *      minMessage = "Locale name must be at least {{ limit }} characters long",
  57.      *      maxMessage = "Locale name cannot be longer than {{ limit }} characters"
  58.      * )
  59.      * @ORM\Column(name="name", type="string", length=45)
  60.      * @Groups({"out"})
  61.      */
  62.     private $name;
  63.     /**
  64.      * @var bool
  65.      *
  66.      * @ORM\Column(type="boolean")
  67.      * @Groups({"out"})
  68.      */
  69.     private $isDefault false;
  70.     /**
  71.      * Get id.
  72.      *
  73.      * @return int
  74.      */
  75.     public function getId()
  76.     {
  77.         return $this->id;
  78.     }
  79.     /**
  80.      * Set code.
  81.      *
  82.      * @param string $code
  83.      *
  84.      * @return Locale
  85.      */
  86.     public function setCode($code)
  87.     {
  88.         $this->code $code;
  89.         return $this;
  90.     }
  91.     /**
  92.      * Get code.
  93.      *
  94.      * @return string
  95.      */
  96.     public function getCode()
  97.     {
  98.         return $this->code;
  99.     }
  100.     /**
  101.      * Set name.
  102.      *
  103.      * @param string $name
  104.      *
  105.      * @return Locale
  106.      */
  107.     public function setName($name)
  108.     {
  109.         $this->name $name;
  110.         return $this;
  111.     }
  112.     /**
  113.      * Get name.
  114.      *
  115.      * @return string
  116.      */
  117.     public function getName()
  118.     {
  119.         return $this->name;
  120.     }
  121.     /**
  122.      * @return int
  123.      */
  124.     public function getIsDefault()
  125.     {
  126.         return $this->isDefault;
  127.     }
  128.     /**
  129.      * @param bool $default
  130.      */
  131.     public function setIsDefault($default false)
  132.     {
  133.         $this->isDefault $default;
  134.     }
  135. }