src/Containers/SettingSection/ListContainer/Entities/MobileAppVersionEntity.php line 69

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\BooleanFilter;
  15. use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
  16. use Doctrine\ORM\Mapping as ORM;
  17. use Doctrine\DBAL\Types\Types;
  18. use Gedmo\Mapping\Annotation as Gedmo;
  19. use Symfony\Component\Serializer\Annotation\Groups;
  20. use App\Containers\SettingSection\ListContainer\Data\Repositories\MobileAppVersionRepository;
  21. use App\Containers\SettingSection\IndexContainer\Entities\TranslationEntity;
  22. use App\Ship\ApiPlatform\Filter\SimpleSearchFilter;
  23. /** 
  24.  * Версии мобильного приложения
  25. */
  26. #[ApiResource(
  27.     routePrefix'/list',
  28.     normalizationContext: ['groups' => 'read'],
  29.     operations: [
  30.         new Get(
  31.             uriTemplate'/app_versions/{id}'requirements: ['id' => '\d+'],
  32.             // security: "is_granted('ROLE_ADMIN') or is_granted('ROLE_USER_CLIENT') or is_granted('ROLE_READONLY')"
  33.         ),
  34.         new Patch(
  35.             uriTemplate'/app_versions/{id}'requirements: ['id' => '\d+'],
  36.             // security: "is_granted('ROLE_ADMIN')"
  37.         ),
  38.         // new Put(
  39.         //     uriTemplate: '/app_versions/{id}', requirements: ['id' => '\d+'],
  40.         //     security: "is_granted('ROLE_ADMIN')"
  41.         // ),
  42.         new Delete(
  43.             uriTemplate'/app_versions/{id}'requirements: ['id' => '\d+'],
  44.             security"is_granted('ROLE_ADMIN')"
  45.         ),
  46.         new Post(
  47.             uriTemplate'/app_versions',
  48.             security"is_granted('ROLE_ADMIN')"
  49.         ),
  50.         new GetCollection(
  51.             uriTemplate'/app_versions',
  52.             // security: "is_granted('ROLE_ADMIN') or is_granted('ROLE_USER_CLIENT') or is_granted('ROLE_READONLY')"
  53.         ),
  54.     ],
  55.     shortName'List_MobileAppVersions'
  56. )]
  57. #[ApiFilter(SearchFilter::class, properties: ['id' => 'exact''operatingSystem' => 'partial''externalCode' => 'partial''version' => 'partial'])]
  58. #[ApiFilter(NumericFilter::class, properties: ['id'])]
  59. #[ApiFilter(RangeFilter::class, properties: ['id'])]
  60. #[ApiFilter(BooleanFilter::class, properties: ['isMandatoryUpdate'])]
  61. #[ApiFilter(OrderFilter::class)]
  62. #[ApiFilter(filterClassSimpleSearchFilter::class, properties: ['operatingSystem''externalCode''version''description'])]
  63. #[ORM\Entity(repositoryClassMobileAppVersionRepository::class)]
  64. #[ORM\Table(name'`list_mobile_app_versions`')]
  65. #[Gedmo\TranslationEntity(class: TranslationEntity::class)]
  66. class MobileAppVersionEntity
  67. {   
  68.     #[ORM\Id]
  69.     #[ORM\GeneratedValue]
  70.     #[ORM\Column(typeTypes::INTEGER)]
  71.     #[Groups(['read'])]
  72.     private ?int $id null;
  73.     // Операционная система
  74.     #[ORM\Column(typeTypes::STRINGlength255)]
  75.     #[Groups(['read'])]
  76.     private string $operatingSystem;
  77.     // Внешний код
  78.     #[ORM\Column(typeTypes::STRINGlength255nullabletrueuniquetrue)]
  79.     #[Groups(['read'])]
  80.     private ?string $externalCode null;
  81.     // Версия
  82.     #[ORM\Column(typeTypes::STRINGlength50nullablefalse)]
  83.     #[Groups(['read'])]
  84.     private string $version;
  85.     // Обязательность обновления
  86.     #[ORM\Column(typeTypes::BOOLEANoptions: ['default' => false])]
  87.     #[Groups(['read'])]
  88.     private bool $isMandatoryUpdate false;
  89.     // Описание
  90.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  91.     #[Gedmo\Translatable]
  92.     #[Groups(['read'])]
  93.     private ?string $description null;
  94.     #[Gedmo\Timestampable(on'create')]
  95.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLE)]
  96.     protected $createdAt;
  97.     #[Gedmo\Timestampable(on'update')]
  98.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLE)]
  99.     protected $updatedAt;
  100.     /**
  101.      * Used locale to override Translation listener`s locale
  102.      * this is not a mapped field of entity metadata, just a simple property
  103.      */
  104.     #[Gedmo\Locale]
  105.     private $locale;
  106.     public function getId(): ?int
  107.     {
  108.         return $this->id;
  109.     }
  110.     public function getOperatingSystem()
  111.     {
  112.         return $this->operatingSystem;
  113.     }
  114.     public function setOperatingSystem($value)
  115.     {
  116.         $this->operatingSystem $value;
  117.         return $this;
  118.     }
  119.     public function getExternalCode()
  120.     {
  121.         return $this->externalCode;
  122.     }
  123.  
  124.     public function setExternalCode($code)
  125.     {
  126.         $this->externalCode $code;
  127.         return $this;
  128.     }
  129.     public function getVersion()
  130.     {
  131.         return $this->version;
  132.     }
  133.  
  134.     public function setVersion($version)
  135.     {
  136.         $this->version $version;
  137.         return $this;
  138.     }
  139.     public function getIsMandatoryUpdate()
  140.     {
  141.         return $this->isMandatoryUpdate;
  142.     }
  143.     public function setIsMandatoryUpdate($isMandatoryUpdate)
  144.     {
  145.         $this->isMandatoryUpdate $isMandatoryUpdate;
  146.         return $this;
  147.     }
  148.     public function getDescription()
  149.     {
  150.         return $this->description;
  151.     }
  152.     public function setDescription($text)
  153.     {
  154.         $this->description $text;
  155.         return $this;
  156.     }
  157.     public function setTranslatableLocale($locale)
  158.     {
  159.         $this->locale $locale;
  160.     }
  161. }