src/Containers/ServiceSection/TravelContainer/Entities/FileEntity.php line 61

Open in your IDE?
  1. <?php
  2. namespace App\Containers\ServiceSection\TravelContainer\Entities;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use ApiPlatform\Metadata\ApiProperty;
  5. use ApiPlatform\Metadata\Delete;
  6. use ApiPlatform\Metadata\Get;
  7. use ApiPlatform\Metadata\GetCollection;
  8. use ApiPlatform\Metadata\Post;
  9. use ApiPlatform\Metadata\ApiFilter;
  10. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  11. use ApiPlatform\Doctrine\Orm\Filter\NumericFilter;
  12. use ApiPlatform\Doctrine\Orm\Filter\RangeFilter;
  13. // use ApiPlatform\Doctrine\Orm\Filter\DateFilter;
  14. use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
  15. use Doctrine\DBAL\Types\Types;
  16. use Doctrine\ORM\Mapping as ORM;
  17. use Symfony\Component\HttpFoundation\File\File;
  18. use Symfony\Component\Serializer\Annotation\Groups;
  19. use Symfony\Component\Serializer\Annotation\MaxDepth;
  20. use Symfony\Component\Validator\Constraints as Assert;
  21. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  22. use Gedmo\Mapping\Annotation as Gedmo;
  23. use App\Containers\ServiceSection\TravelContainer\Data\Repositories\FileRepository;
  24. use App\Containers\CrmSection\EquipmentContainer\Entities\ApplicationEntity;
  25. #[ApiResource(
  26.     routePrefix'/service',
  27.     normalizationContext: [
  28.         'groups' => ['travel:read''file:travel:read''read'],
  29.         'enable_max_depth' => true
  30.     ],
  31.     denormalizationContext: [
  32.         'groups' => ['file:travel:create''file:travel:update']
  33.     ],
  34.     types: ['https://schema.org/MediaObject'],
  35.     operations: [
  36.         new Get(
  37.             uriTemplate'/travel_files/{id}'requirements: ['id' => '\d+'],
  38.             validationContext: ['groups' => ['file:travel:read']],
  39.             security"is_granted('ROLE_ADMIN') or is_granted('ROLE_USER_CLIENT') or is_granted('ROLE_READONLY')"
  40.         ),
  41.         new GetCollection(
  42.             uriTemplate'/travel_files',
  43.             validationContext: ['groups' => ['file:travel:read']],
  44.             security"is_granted('ROLE_ADMIN') or is_granted('ROLE_USER_CLIENT') or is_granted('ROLE_READONLY')"
  45.         ),
  46.     ],
  47.     shortName'Service_Travels'
  48. )]
  49. #[ApiFilter(SearchFilter::class, properties: [
  50.     'id' => 'exact'
  51. ])]
  52. #[ApiFilter(NumericFilter::class, properties: ['id'])]
  53. #[ApiFilter(RangeFilter::class, properties: ['id'])]
  54. #[ApiFilter(OrderFilter::class)]
  55. #[ORM\Entity(repositoryClassFileRepository::class)]
  56. #[ORM\Table(name'`service_travels_files`')]
  57. #[Vich\Uploadable]
  58. class FileEntity
  59. {
  60.     #[ORM\Id]
  61.     #[ORM\GeneratedValue]
  62.     #[ORM\Column(typeTypes::INTEGER)]
  63.     #[Groups(['read''file:travel:read'])]
  64.     private ?int $id null;
  65.     #[ORM\Column(typeTypes::STRINGlength20nullablefalse)]
  66.     #[Assert\Length(min0max20groups: ['file:travel:update''file:travel:create'])]
  67.     #[Groups(['file:travel:read''file:travel:update''file:travel:create'])]
  68.     #[ApiProperty(security"is_granted('ROLE_ADMIN')")]
  69.     private string $extStartTimestamp;
  70.     #[ORM\Column(typeTypes::STRINGlength20nullablefalse)]
  71.     #[Assert\Length(min0max20groups: ['file:travel:update''file:travel:create'])]
  72.     #[Groups(['file:travel:read''file:travel:update''file:travel:create'])]
  73.     #[ApiProperty(security"is_granted('ROLE_ADMIN')")]
  74.     private string $extEndTimestamp;
  75.     #[ORM\ManyToOne(targetEntityApplicationEntity::class)]
  76.     #[ORM\JoinColumn(name'application_id'referencedColumnName'id'nullablefalse)]
  77.     #[Assert\NotNull(groups: ['file:travel:update''file:travel:create'])]
  78.     #[Assert\NotBlank(groups: ['file:travel:update''file:travel:create'])]
  79.     #[Groups(['file:travel:read''file:travel:update''file:travel:create'])]
  80.     #[MaxDepth(1)]
  81.     private ApplicationEntity $application;
  82.     #[ApiProperty(types: ['https://schema.org/contentUrl'])]
  83.     #[Groups(['read''file:travel:read'])]
  84.     public ?string $contentUrl null;
  85.     #[Vich\UploadableField(mapping'travels_object'fileNameProperty'filePath')]
  86.     #[Assert\NotNull(groups: ['file:travel:read''file:travel:update''file:travel:create'])]
  87.     public ?File $file null;
  88.     #[ORM\Column(nullabletrue)]
  89.     public ?string $filePath null;
  90.     #[Gedmo\Timestampable(on'create')]
  91.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLE)]
  92.     private $createdAt;
  93.     #[Gedmo\Timestampable(on'update')]
  94.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLE)]
  95.     private $updatedAt;
  96.   
  97.     public function getId(): ?int
  98.     {
  99.         return $this->id;
  100.     }
  101.     public function getExtStartTimestamp(): ?string
  102.     {
  103.         return $this->extStartTimestamp;
  104.     }
  105.     public function setExtStartTimestamp($value): ?self
  106.     {
  107.         $this->extStartTimestamp $value;
  108.         return $this;
  109.     }
  110.     public function getExtEndTimestamp(): ?string
  111.     {
  112.         return $this->extEndTimestamp;
  113.     }
  114.     public function setExtEndTimestamp($value): ?self
  115.     {
  116.         $this->extEndTimestamp $value;
  117.         return $this;
  118.     }
  119.     public function getApplication(): ?ApplicationEntity
  120.     {
  121.         return $this->application;
  122.     }
  123.     public function setApplication($application): ?self
  124.     {
  125.         $this->application $application;
  126.         return $this;
  127.     }
  128.     public function getCreatedAt(): ?\DateTimeInterface
  129.     {
  130.         return $this->createdAt;
  131.     }
  132.     public function getUpdatedAt(): ?\DateTimeInterface
  133.     {
  134.         return $this->updatedAt;
  135.     }
  136. }