src/Containers/SettingSection/ListContainer/Entities/CallStateEntity.php line 68

Open in your IDE?
  1. <?php
  2. namespace App\Containers\SettingSection\ListContainer\Entities;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use ApiPlatform\Metadata\Delete;
  5. use ApiPlatform\Metadata\Get;
  6. use ApiPlatform\Metadata\GetCollection;
  7. use ApiPlatform\Metadata\Patch;
  8. use ApiPlatform\Metadata\Put;
  9. use ApiPlatform\Metadata\Post;
  10. use ApiPlatform\Metadata\ApiFilter;
  11. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  12. use ApiPlatform\Doctrine\Orm\Filter\NumericFilter;
  13. use ApiPlatform\Doctrine\Orm\Filter\RangeFilter;
  14. use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
  15. use Symfony\Component\Serializer\Annotation\Groups;
  16. use Doctrine\ORM\Mapping as ORM;
  17. use Doctrine\DBAL\Types\Types;
  18. use Gedmo\Mapping\Annotation as Gedmo;
  19. use App\Containers\SettingSection\ListContainer\Data\Repositories\CallStateRepository;
  20. use App\Containers\SettingSection\IndexContainer\Entities\TranslationEntity;
  21. use App\Ship\ApiPlatform\Filter\SimpleSearchFilter;
  22. /** 
  23.  * Состояния звонков
  24. */
  25. #[ApiResource(
  26.     routePrefix'/list',
  27.     normalizationContext: ['groups' => 'read'],
  28.     operations: [
  29.         new Get(
  30.             uriTemplate'/call_states/{id}'requirements: ['id' => '\d+'],
  31.             security"is_granted('ROLE_ADMIN') or is_granted('ROLE_USER_CLIENT') or is_granted('ROLE_READONLY')"
  32.         ),
  33.         new Patch(
  34.             uriTemplate'/call_states/{id}'requirements: ['id' => '\d+'],
  35.             security"is_granted('ROLE_ADMIN')"
  36.         ),
  37.         // new Put(
  38.         //     uriTemplate: '/call_states/{id}', requirements: ['id' => '\d+'],
  39.         //     security: "is_granted('ROLE_ADMIN')"
  40.         // ),
  41.         // new Delete(
  42.         //     uriTemplate: '/call_states/{id}', requirements: ['id' => '\d+'],
  43.         //     security: "is_granted('ROLE_ADMIN')"
  44.         // ),
  45.         // new Post(
  46.         //     uriTemplate: '/call_states',
  47.         //     security: "is_granted('ROLE_ADMIN')"
  48.         // ),
  49.         new GetCollection(
  50.             uriTemplate'/call_states',
  51.             security"is_granted('ROLE_ADMIN') or is_granted('ROLE_USER_CLIENT') or is_granted('ROLE_READONLY')"
  52.         ),
  53.     ],
  54.     shortName'List_CallStates'
  55. )]
  56. #[ApiFilter(SearchFilter::class, properties: ['id' => 'exact''name' => 'partial''code' => 'partial'])]
  57. #[ApiFilter(NumericFilter::class, properties: ['id''sorting'])]
  58. #[ApiFilter(RangeFilter::class, properties: ['id''sorting'])]
  59. #[ApiFilter(OrderFilter::class)]
  60. #[ApiFilter(filterClassSimpleSearchFilter::class, properties: ['name''code'])]
  61. #[ORM\Entity(repositoryClassCallStateRepository::class)]
  62. #[ORM\Table(name'`list_call_states`')]
  63. #[ORM\Index(columns: ['code'], name'list_call_states_custom_idx')]
  64. #[Gedmo\TranslationEntity(class: TranslationEntity::class)]
  65. class CallStateEntity
  66. {   
  67.     #[ORM\Id]
  68.     #[ORM\GeneratedValue]
  69.     #[ORM\Column(typeTypes::INTEGER)]
  70.     #[Groups(['read'])]
  71.     private ?int $id null;
  72.     // Название
  73.     #[ORM\Column(typeTypes::STRINGlength255nullablefalse)]
  74.     #[Gedmo\Translatable]
  75.     #[Groups(['read'])]
  76.     private string $name;
  77.     // Сортировка
  78.     #[ORM\Column(typeTypes::INTEGERoptions: ['default' => 500])]
  79.     #[Groups(['read'])]
  80.     private int $sorting 500;
  81.     // Код
  82.     #[ORM\Column(typeTypes::STRINGlength50nullablefalseuniquetrue)]
  83.     #[Groups(['read'])]
  84.     private string $code;
  85.     #[Gedmo\Timestampable(on'create')]
  86.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLE)]
  87.     protected $createdAt;
  88.     #[Gedmo\Timestampable(on'update')]
  89.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLE)]
  90.     protected $updatedAt;
  91.     /**
  92.      * Used locale to override Translation listener`s locale
  93.      * this is not a mapped field of entity metadata, just a simple property
  94.      */
  95.     #[Gedmo\Locale]
  96.     private $locale;
  97.     public function getId(): ?int
  98.     {
  99.         return $this->id;
  100.     }
  101.     public function getName()
  102.     {
  103.         return $this->name;
  104.     }
  105.     public function setName($name)
  106.     {
  107.         $this->name $name;
  108.         return $this;
  109.     }
  110.     public function getSorting()
  111.     {
  112.         return $this->sorting;
  113.     }
  114.     public function setSorting($value)
  115.     {
  116.         $this->sorting $value;
  117.         return $this;
  118.     }
  119.     public function getCode()
  120.     {
  121.         return $this->code;
  122.     }
  123.     public function setCode($code)
  124.     {
  125.         $this->code $code;
  126.         return $this;
  127.     }
  128.     public function setTranslatableLocale($locale)
  129.     {
  130.         $this->locale $locale;
  131.     }
  132. }