ApiLegacyStorage.php 686 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Service\File\Storage;
  4. use App\Entity\Core\File;
  5. use App\Service\ApiLegacy\ApiLegacyRequestService;
  6. /**
  7. * Read and write files into the Opentalent API v1 storage
  8. */
  9. class ApiLegacyStorage implements FileStorageInterface
  10. {
  11. public function __construct(private ApiLegacyRequestService $apiLegacyRequestService)
  12. {}
  13. /**
  14. * Reads the given file and returns its content as a string
  15. *
  16. * @param File $file
  17. * @return string
  18. */
  19. public function read(File $file): string
  20. {
  21. $url = '_internal/secure/files/' . $file->getId();
  22. return $this->apiLegacyRequestService->getContent($url);
  23. }
  24. }