ExportRequest.php 2.3 KB

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