ExportRequest.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\ApiResources\Export;
  4. use ApiPlatform\Metadata\ApiProperty;
  5. use Symfony\Component\Validator\Constraints as Assert;
  6. use App\Enum\Export\ExportFormatEnum;
  7. /**
  8. * Demande d'export d'un fichier
  9. * -- C'est la classe de base des ressources de type ExportRequest --
  10. */
  11. abstract class ExportRequest
  12. {
  13. /**
  14. * Id 'bidon' ajouté par défaut pour permettre la construction
  15. * de l'IRI par api platform
  16. *
  17. * @var int
  18. */
  19. #[ApiProperty(identifier: true)]
  20. protected int $id = 0;
  21. /**
  22. * Format de sortie attendu (pdf, txt...)
  23. */
  24. #[Assert\Type(type: ExportFormatEnum::class)]
  25. protected ExportFormatEnum $format;
  26. /**
  27. * The id of the access requesting this export
  28. * @var int|null
  29. */
  30. protected ?int $requesterId = null;
  31. /**
  32. * Should the export be asynchrone
  33. * @var bool
  34. */
  35. protected bool $async = true;
  36. /**
  37. * The id of the db record of the file
  38. * @var int|null
  39. */
  40. protected ?int $fileId = null;
  41. /**
  42. * @return int
  43. */
  44. public function getId(): int
  45. {
  46. return $this->id;
  47. }
  48. public function getFormat(): ExportFormatEnum
  49. {
  50. return $this->format;
  51. }
  52. public function setFormat(ExportFormatEnum $format): void
  53. {
  54. $this->format = $format;
  55. }
  56. /**
  57. * @return int|null
  58. */
  59. public function getRequesterId(): ?int
  60. {
  61. return $this->requesterId;
  62. }
  63. /**
  64. * @param int|null $requesterId
  65. */
  66. public function setRequesterId(?int $requesterId): void
  67. {
  68. $this->requesterId = $requesterId;
  69. }
  70. /**
  71. * @return bool
  72. */
  73. public function isAsync(): bool
  74. {
  75. return $this->async;
  76. }
  77. /**
  78. * @param bool $async
  79. */
  80. public function setAsync(bool $async): void
  81. {
  82. $this->async = $async;
  83. }
  84. /**
  85. * @return int|null
  86. */
  87. public function getFileId(): ?int
  88. {
  89. return $this->fileId;
  90. }
  91. /**
  92. * @param int|null $fileId
  93. */
  94. public function setFileId(?int $fileId): void
  95. {
  96. $this->fileId = $fileId;
  97. }
  98. }