ApiLegacyStorage.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Service\File\Storage;
  4. use App\Entity\Access\Access;
  5. use App\Entity\Core\File;
  6. use App\Service\ApiLegacy\ApiLegacyRequestService;
  7. use App\Service\Utils\UrlBuilder;
  8. use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
  9. use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
  10. use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
  11. use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
  12. use Symfony\Contracts\HttpClient\HttpClientInterface;
  13. /**
  14. * Read and write files into the Opentalent API v1 storage
  15. */
  16. class ApiLegacyStorage implements FileStorageInterface
  17. {
  18. public function __construct(private ApiLegacyRequestService $apiLegacyRequestService)
  19. {}
  20. public function exists(File $file, string $content, Access $author): File {
  21. throw new \RuntimeException('not implemented error');
  22. }
  23. /**
  24. * Reads the given file and returns its content as a string
  25. *
  26. * @param File $file
  27. * @return string
  28. */
  29. public function read(File $file): string
  30. {
  31. $url = '_internal/secure/files/' . $file->getId();
  32. return $this->apiLegacyRequestService->getContent($url);
  33. }
  34. public function write(File $file, string $content, Access $author): File {
  35. throw new \RuntimeException('not implemented error');
  36. }
  37. }