src/Containers/CrmSection/PrintablesContainer/Entities/ProviderEntity.php line 71

Open in your IDE?
  1. <?php
  2. namespace App\Containers\CrmSection\PrintablesContainer\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\CrmSection\PrintablesContainer\Data\Repositories\ProviderRepository;
  20. use App\Containers\CrmSection\IndexContainer\Entities\TranslationEntity;
  21. /** 
  22.  * Провайдер печатных форм
  23. */
  24. #[ApiResource(
  25.     routePrefix'/crm',
  26.     normalizationContext: ['groups' => 'read'],
  27.     operations: [
  28.         new Get(
  29.             uriTemplate'/printable_providers/{id}'requirements: ['id' => '\d+'],
  30.             security"is_granted('ROLE_ADMIN') or is_granted('ROLE_USER_CLIENT')"
  31.         ),
  32.         new Patch(
  33.             uriTemplate'/printable_providers/{id}'requirements: ['id' => '\d+'],
  34.             security"is_granted('ROLE_ADMIN')"
  35.         ),
  36.         // new Put(
  37.         //     uriTemplate: '/printable_providers/{id}', requirements: ['id' => '\d+'],
  38.         //     security: "is_granted('ROLE_ADMIN')"
  39.         // ),
  40.         new Delete(
  41.             uriTemplate'/printable_providers/{id}'requirements: ['id' => '\d+'],
  42.             security"is_granted('ROLE_ADMIN')"
  43.         ),
  44.         new Post(
  45.             uriTemplate'/printable_providers',
  46.             security"is_granted('ROLE_ADMIN')"
  47.         ),
  48.         new GetCollection(
  49.             uriTemplate'/printable_providers',
  50.             security"is_granted('ROLE_ADMIN') or is_granted('ROLE_USER_CLIENT')"
  51.         ),
  52.     ],
  53.     shortName'CRM_Printables'
  54. )]
  55. #[ApiFilter(SearchFilter::class, properties: [
  56.     'id' => 'exact',
  57.     'name' => 'exact',
  58.     'objectClass' => 'exact',
  59.     'taskClass' => 'exact'
  60. ])]
  61. #[ApiFilter(NumericFilter::class, properties: ['id''sorting'])]
  62. #[ApiFilter(RangeFilter::class, properties: ['id''sorting'])]
  63. #[ApiFilter(OrderFilter::class)]
  64. #[ORM\Entity(repositoryClassProviderRepository::class)]
  65. #[ORM\Table(name'`crm_printable_providers`')]
  66. #[ORM\Index(columns: ['object_class''task_class'], name'crm_printable_providers_custom_idx')]
  67. #[Gedmo\TranslationEntity(class: TranslationEntity::class)]
  68. class ProviderEntity
  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::STRINGlength150nullablefalse)]
  77.     #[Gedmo\Translatable]
  78.     #[Groups(['read'])]
  79.     private string $name;
  80.     // Сортировка
  81.     #[ORM\Column(typeTypes::INTEGERoptions: ['default' => 500])]
  82.     #[Groups(['read'])]
  83.     private int $sorting 500;
  84.     // Класс объекта
  85.     #[ORM\Column(typeTypes::STRINGlength191nullablefalseuniquetrue)]
  86.     private string $objectClass;
  87.     // Класс обработчика
  88.     #[ORM\Column(typeTypes::STRINGlength191nullablefalseuniquetrue)]
  89.     private string $taskClass;
  90.     #[Gedmo\Timestampable(on'create')]
  91.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLE)]
  92.     protected $createdAt;
  93.     #[Gedmo\Timestampable(on'update')]
  94.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLE)]
  95.     protected $updatedAt;
  96.     /**
  97.      * Used locale to override Translation listener`s locale
  98.      * this is not a mapped field of entity metadata, just a simple property
  99.      */
  100.     #[Gedmo\Locale]
  101.     private $locale;
  102.     public function getId(): ?int
  103.     {
  104.         return $this->id;
  105.     }
  106.     public function getName()
  107.     {
  108.         return $this->name;
  109.     }
  110.     public function setName($name)
  111.     {
  112.         $this->name $name;
  113.         return $this;
  114.     }
  115.     public function getSorting()
  116.     {
  117.         return $this->sorting;
  118.     }
  119.     public function setSorting($value)
  120.     {
  121.         $this->sorting $value;
  122.         return $this;
  123.     }
  124.     public function setObjectClass($class)
  125.     {
  126.         $this->objectClass $class;
  127.         return $this;
  128.     }
  129.     public function getObjectClass()
  130.     {
  131.         return $this->objectClass;
  132.     }
  133.     public function setTaskClass($class)
  134.     {
  135.         $this->taskClass $class;
  136.         return $this;
  137.     }
  138.     public function getTaskClass()
  139.     {
  140.         return $this->taskClass;
  141.     }
  142.     public function setTranslatableLocale($locale)
  143.     {
  144.         $this->locale $locale;
  145.     }
  146. }