src/Entity/DataTmp.php line 54

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use ApiPlatform\Metadata\Get;
  5. use ApiPlatform\Metadata\Post;
  6. use ApiPlatform\Metadata\Put;
  7. use App\Controller\Action\UploadDataTmpFileAction;
  8. use App\Repository\DataTmpRepository;
  9. use Doctrine\DBAL\Types\Types;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Doctrine\ORM\Mapping\PreUpdate;
  12. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  13. use Symfony\Component\HttpFoundation\File\File;
  14. #[ORM\Entity(repositoryClassDataTmpRepository::class)]
  15. #[ApiResource(
  16.     operations: [
  17.         new Get(),
  18.         new Post(
  19.             controllerUploadDataTmpFileAction::class, 
  20.             deserializefalse
  21.             uriTemplate'/data_tmps/upload',
  22.             openapiContext: [
  23.                 'requestBody' => [
  24.                     'content' => [
  25.                         'multipart/form-data' => [
  26.                             'schema' => [
  27.                                 'type' => 'object'
  28.                                 'properties' => [
  29.                                     'site'=> [
  30.                                         'type' => 'string'
  31.                                         'format' => 'int'
  32.                                     ],
  33.                                     'type'=> [
  34.                                         'type' => 'string'
  35.                                         'format' => 'string'
  36.                                     ],
  37.                                     'file' => [
  38.                                         'type' => 'string'
  39.                                         'format' => 'binary'
  40.                                     ]
  41.                                 ]
  42.                             ]
  43.                         ]
  44.                     ]
  45.                 ]
  46.             ]
  47.         )
  48.     ]
  49. )]
  50. #[ORM\HasLifecycleCallbacks]
  51. class DataTmp
  52. {
  53.     const PENDING_STATUS 'pending';
  54.     const COMPLETE_STATUS 'complete';
  55.     const DOCUMENT_TYPE 'document';
  56.     const EVALUATION_TYPE 'evaluation';
  57.     const COMPLIANCE_TYPE 'compliance';
  58.     const SYNTHESE_TYPE 'synthese';
  59.     const DOCUMENT_OFFICILE_TYPE 'document_officile';
  60.     #[ORM\Column(name'id'type'bigint'nullablefalse)]
  61.     #[ORM\Id]
  62.     #[ORM\GeneratedValue(strategy'IDENTITY')]
  63.     private int $id;
  64.     #[Vich\UploadableField(mapping"datatmp"fileNameProperty"path")]
  65.     public ?File $fileObject null;
  66.     #[ORM\Column(typeTypes::BIGINTnullabletrue)]
  67.     private ?string $siteId null;
  68.     #[ORM\Column(type'text'nullabletrue)]
  69.     private ?string $path null;
  70.     #[ORM\Column(type'text'nullabletrue)]
  71.     private ?string $parent null;
  72.     #[ORM\Column(type'text'nullabletrue)]
  73.     private ?string $file null;
  74.     #[ORM\Column(length200nullabletrue)]
  75.     private ?string $type null;
  76.     #[ORM\Column(length50nullabletrue)]
  77.     private ?string $status self::PENDING_STATUS;
  78.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  79.     private ?\DateTimeInterface $startTime null;
  80.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  81.     private ?\DateTimeInterface $endTime null;
  82.     public function getId(): int
  83.     {
  84.         return $this->id;
  85.     }
  86.     public function getSiteId(): ?string
  87.     {
  88.         return $this->siteId;
  89.     }
  90.     public function setSiteId(?string $siteId): self
  91.     {
  92.         $this->siteId $siteId;
  93.         return $this;
  94.     }
  95.     public function getPath(): ?string
  96.     {
  97.         return $this->path;
  98.     }
  99.     public function setPath(?string $path): self
  100.     {
  101.         $this->path $path;
  102.         return $this;
  103.     }
  104.     public function getParent(): ?string
  105.     {
  106.         return $this->parent;
  107.     }
  108.     public function setParent(?string $parent): self
  109.     {
  110.         $this->parent $parent;
  111.         return $this;
  112.     }
  113.     public function getFile(): ?string
  114.     {
  115.         return $this->file;
  116.     }
  117.     public function setFile(?string $file): self
  118.     {
  119.         $this->file $file;
  120.         return $this;
  121.     }
  122.     public function getType(): ?string
  123.     {
  124.         return $this->type;
  125.     }
  126.     public function setType(?string $type): self
  127.     {
  128.         $this->type $type;
  129.         return $this;
  130.     }
  131.     public function getStatus(): ?string
  132.     {
  133.         return $this->status;
  134.     }
  135.     public function setStatus(?string $status): self
  136.     {
  137.         $this->status $status;
  138.         return $this;
  139.     }
  140.     public function getStartTime(): ?\DateTimeInterface
  141.     {
  142.         return $this->startTime;
  143.     }
  144.     public function setStartTime(?\DateTimeInterface $startTime): self
  145.     {
  146.         $this->startTime $startTime;
  147.         return $this;
  148.     }
  149.     public function getEndTime(): ?\DateTimeInterface
  150.     {
  151.         return $this->endTime;
  152.     }
  153.     public function setEndTime(?\DateTimeInterface $endTime): self
  154.     {
  155.         $this->endTime $endTime;
  156.         return $this;
  157.     }
  158.     #[PreUpdate]
  159.     public function updateUpdatedAt()
  160.     {
  161.         $this->startTime = new \DateTime('now');
  162.         $this->endTime = new \DateTime('now');
  163.     }
  164. }