src/Containers/ServiceSection/EventLogContainer/Entities/EventTypeEntity.php line 51

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