src/Containers/SettingSection/ListContainer/Entities/TrackingSystemEntity.php line 71

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 Doctrine\ORM\Mapping as ORM;
  16. use Doctrine\DBAL\Types\Types;
  17. use Gedmo\Mapping\Annotation as Gedmo;
  18. use Symfony\Component\Serializer\Annotation\Groups;
  19. use App\Containers\SettingSection\ListContainer\Data\Repositories\TrackingSystemRepository;
  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: [
  28.         'groups' => 'read',
  29.         'enable_max_depth' => true
  30.     ],
  31.     operations: [
  32.         new Get(
  33.             uriTemplate'/tracking_systems/{id}'requirements: ['id' => '\d+'],
  34.             security"is_granted('ROLE_ADMIN') or is_granted('ROLE_USER_CLIENT') or is_granted('ROLE_READONLY')"
  35.         ),
  36.         new Patch(
  37.             uriTemplate'/tracking_systems/{id}'requirements: ['id' => '\d+'],
  38.             security"is_granted('ROLE_ADMIN')"
  39.         ),
  40.         // new Put(
  41.         //     uriTemplate: '/tracking_systems/{id}', requirements: ['id' => '\d+'],
  42.         //     security: "is_granted('ROLE_ADMIN')"
  43.         // ),
  44.         new Delete(
  45.             uriTemplate'/tracking_systems/{id}'requirements: ['id' => '\d+'],
  46.             security"is_granted('ROLE_ADMIN')"
  47.         ),
  48.         new Post(
  49.             uriTemplate'/tracking_systems',
  50.             security"is_granted('ROLE_ADMIN')"
  51.         ),
  52.         new GetCollection(
  53.             uriTemplate'/tracking_systems',
  54.             security"is_granted('ROLE_ADMIN') or is_granted('ROLE_USER_CLIENT') or is_granted('ROLE_READONLY')"
  55.         ),
  56.     ],
  57.     shortName'List_TrackingSystems'
  58. )]
  59. #[ApiFilter(SearchFilter::class, properties: ['id' => 'exact''name' => 'partial''externalCode' => 'partial'])]
  60. #[ApiFilter(NumericFilter::class, properties: ['id'])]
  61. #[ApiFilter(RangeFilter::class, properties: ['id'])]
  62. #[ApiFilter(OrderFilter::class)]
  63. #[ApiFilter(filterClassSimpleSearchFilter::class, properties: ['name''externalCode'])]
  64. #[ORM\Entity(repositoryClassTrackingSystemRepository::class)]
  65. #[ORM\Table(name'`list_tracking_systems`')]
  66. #[ORM\Index(columns: ['service_code'], name'list_tracking_systems_custom_idx')]
  67. #[Gedmo\TranslationEntity(class: TranslationEntity::class)]
  68. class TrackingSystemEntity
  69. {   
  70.     #[ORM\Id]
  71.     #[ORM\GeneratedValue]
  72.     #[ORM\Column(typeTypes::INTEGER)]
  73.     #[Groups(['read'])]
  74.     private ?int $id null;
  75.     // Название
  76.     #[ORM\Column(typeTypes::STRINGlength255nullablefalse)]
  77.     #[Gedmo\Translatable]
  78.     #[Groups(['read'])]
  79.     private string $name;
  80.     #[ORM\Column(typeTypes::STRINGlength255nullabletrueuniquetrue)]
  81.     #[Groups(['read'])]
  82.     private ?string $externalCode null;
  83.     // Сортировка
  84.     #[ORM\Column(typeTypes::INTEGERoptions: ['default' => 500])]
  85.     #[Groups(['read'])]
  86.     private int $sorting 500;
  87.     // Код сервиса в системе
  88.     #[ORM\Column(typeTypes::STRINGlength50nullablefalseuniquetrue)]
  89.     #[Groups(['read'])]
  90.     private string $serviceCode;
  91.     // Электронные адреса установщиков
  92.     #[ORM\Column(typeTypes::STRINGlength255nullabletrue)]
  93.     #[Groups(['read'])]
  94.     private ?string $responsibleEmails null;
  95.     #[Gedmo\Timestampable(on'create')]
  96.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLE)]
  97.     protected $createdAt;
  98.     #[Gedmo\Timestampable(on'update')]
  99.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLE)]
  100.     protected $updatedAt;
  101.     /**
  102.      * Used locale to override Translation listener`s locale
  103.      * this is not a mapped field of entity metadata, just a simple property
  104.      */
  105.     #[Gedmo\Locale]
  106.     private $locale;
  107.     public function getId(): ?int
  108.     {
  109.         return $this->id;
  110.     }
  111.     public function getName()
  112.     {
  113.         return $this->name;
  114.     }
  115.     public function setName($name)
  116.     {
  117.         $this->name $name;
  118.         return $this;
  119.     }
  120.     public function getExternalCode()
  121.     {
  122.         return $this->externalCode;
  123.     }
  124.     public function setExternalCode($code)
  125.     {
  126.         $this->externalCode $code;
  127.         return $this;
  128.     }
  129.     public function getSorting()
  130.     {
  131.         return $this->sorting;
  132.     }
  133.     public function setSorting($value)
  134.     {
  135.         $this->sorting $value;
  136.         return $this;
  137.     }
  138.     public function getServiceCode()
  139.     {
  140.         return $this->serviceCode;
  141.     }
  142.     public function setServiceCode($code)
  143.     {
  144.         $this->serviceCode $code;
  145.         return $this;
  146.     }
  147.     public function getResponsibleEmails()
  148.     {
  149.         return $this->responsibleEmails;
  150.     }
  151.     public function setResponsibleEmails($value)
  152.     {
  153.         $this->responsibleEmails $value;
  154.         return $this;
  155.     }
  156.     public function setTranslatableLocale($locale)
  157.     {
  158.         $this->locale $locale;
  159.     }
  160. }