ExportRequest.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. * @var string
  24. */
  25. #[Assert\Choice(callback: [ExportFormatEnum::class, 'toArray'], message: 'invalid-output-format')]
  26. protected string $format;
  27. /**
  28. * The id of the access requesting this export
  29. * @var int|null
  30. */
  31. protected ?int $requesterId = null;
  32. /**
  33. * Should the export be asynchrone
  34. * @var bool
  35. */
  36. protected bool $async = true;
  37. /**
  38. * The id of the db record of the file
  39. * @var int|null
  40. */
  41. protected ?int $fileId = null;
  42. /**
  43. * @return int
  44. */
  45. public function getId(): int
  46. {
  47. return $this->id;
  48. }
  49. /**
  50. * @return string
  51. */
  52. public function getFormat(): string
  53. {
  54. return $this->format;
  55. }
  56. /**
  57. * @param string $format
  58. */
  59. public function setFormat(string $format): void
  60. {
  61. $this->format = $format;
  62. }
  63. /**
  64. * @return int|null
  65. */
  66. public function getRequesterId(): ?int
  67. {
  68. return $this->requesterId;
  69. }
  70. /**
  71. * @param int|null $requesterId
  72. */
  73. public function setRequesterId(?int $requesterId): void
  74. {
  75. $this->requesterId = $requesterId;
  76. }
  77. /**
  78. * @return bool
  79. */
  80. public function isAsync(): bool
  81. {
  82. return $this->async;
  83. }
  84. /**
  85. * @param bool $async
  86. */
  87. public function setAsync(bool $async): void
  88. {
  89. $this->async = $async;
  90. }
  91. /**
  92. * @return int|null
  93. */
  94. public function getFileId(): ?int
  95. {
  96. return $this->fileId;
  97. }
  98. /**
  99. * @param int|null $fileId
  100. */
  101. public function setFileId(?int $fileId): void
  102. {
  103. $this->fileId = $fileId;
  104. }
  105. }