src/Containers/SettingSection/ListContainer/Entities/MessageEventEntity.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\MessageEventRepository;
  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'/message_events/{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'/message_events/{id}'requirements: ['id' => '\d+'],
  35.             security"is_granted('ROLE_ADMIN')"
  36.         ),
  37.         // new Put(
  38.         //     uriTemplate: '/message_events/{id}', requirements: ['id' => '\d+'],
  39.         //     security: "is_granted('ROLE_ADMIN')"
  40.         // ),
  41.         new Delete(
  42.             uriTemplate'/message_events/{id}'requirements: ['id' => '\d+'],
  43.             security"is_granted('ROLE_ADMIN')"
  44.         ),
  45.         new Post(
  46.             uriTemplate'/message_events',
  47.             security"is_granted('ROLE_ADMIN')"
  48.         ),
  49.         new GetCollection(
  50.             uriTemplate'/message_events',
  51.             security"is_granted('ROLE_ADMIN') or is_granted('ROLE_USER_CLIENT') or is_granted('ROLE_READONLY')"
  52.         ),
  53.     ],
  54.     shortName'List_MessageEvents'
  55. )]
  56. #[ApiFilter(SearchFilter::class, properties: ['id' => 'exact''name' => 'partial''externalCode' => 'partial'])]
  57. #[ApiFilter(NumericFilter::class, properties: ['id'])]
  58. #[ApiFilter(RangeFilter::class, properties: ['id'])]
  59. #[ApiFilter(OrderFilter::class)]
  60. #[ApiFilter(filterClassSimpleSearchFilter::class, properties: ['name''externalCode'])]
  61. #[ORM\Entity(repositoryClassMessageEventRepository::class)]
  62. #[ORM\Table(name'`list_message_events`')]
  63. #[ORM\Index(columns: ['code'], name'list_message_events_custom_idx')]
  64. #[Gedmo\TranslationEntity(class: TranslationEntity::class)]
  65. class MessageEventEntity
  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.     #[ORM\Column(typeTypes::STRINGlength150nullablefalseuniquetrue)]
  78.     #[Groups(['read'])]
  79.     private string $code;
  80.     #[ORM\Column(typeTypes::STRINGlength255nullabletrueuniquetrue)]
  81.     #[Groups(['read'])]
  82.     private ?string $externalCode null;
  83.     // Сортування
  84.     #[ORM\Column(typeTypes::INTEGERlength10options: ['default' => 500])]
  85.     #[Groups(['read'])]
  86.     private ?int $sorting 500;
  87.     // Заголовок сообщения
  88.     #[ORM\Column(typeTypes::STRINGlength255nullabletrue)]
  89.     #[Gedmo\Translatable]
  90.     #[Groups(['read'])]
  91.     private ?string $title null;
  92.     // Текст сообщения
  93.     #[ORM\Column(typeTypes::TEXTnullablefalse)]
  94.     #[Gedmo\Translatable]
  95.     #[Groups(['read'])]
  96.     private string $text;
  97.     #[Gedmo\Timestampable(on'create')]
  98.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLE)]
  99.     protected $createdAt;
  100.     #[Gedmo\Timestampable(on'update')]
  101.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLE)]
  102.     protected $updatedAt;
  103.     /**
  104.      * Used locale to override Translation listener`s locale
  105.      * this is not a mapped field of entity metadata, just a simple property
  106.      */
  107.     #[Gedmo\Locale]
  108.     private $locale;
  109.     
  110.     public function getId(): ?int
  111.     {
  112.         return $this->id;
  113.     }
  114.     public function getName()
  115.     {
  116.         return $this->name;
  117.     }
  118.     public function setName($name)
  119.     {
  120.         $this->name $name;
  121.         return $this;
  122.     }
  123.     public function getCode()
  124.     {
  125.         return $this->code;
  126.     }
  127.     public function setCode($code)
  128.     {
  129.         $this->code $code;
  130.         return $this;
  131.     }
  132.     public function getExternalCode()
  133.     {
  134.         return $this->externalCode;
  135.     }
  136.     public function setExternalCode($code)
  137.     {
  138.         $this->externalCode $code;
  139.         return $this;
  140.     }
  141.     public function getSorting()
  142.     {
  143.         return $this->sorting;
  144.     }
  145.     public function setSorting($sorting)
  146.     {
  147.         $this->sorting $sorting;
  148.         return $this;
  149.     }
  150.     public function getTitle()
  151.     {
  152.         return $this->title;
  153.     }
  154.     public function setTitle($title)
  155.     {
  156.         $this->title $title;
  157.         return $this;
  158.     }
  159.     public function getText()
  160.     {
  161.         return $this->text;
  162.     }
  163.     public function setText($text)
  164.     {
  165.         $this->text $text;
  166.         return $this;
  167.     }
  168.     public function setTranslatableLocale($locale)
  169.     {
  170.         $this->locale $locale;
  171.     }
  172. }