InvalidBackend.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud GmbH.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCA\Files_External\Lib\Backend;
  8. use OCA\Files_External\Lib\StorageConfig;
  9. use OCP\Files\StorageNotAvailableException;
  10. use OCP\IUser;
  11. /**
  12. * Invalid storage backend representing a backend
  13. * that could not be resolved
  14. */
  15. class InvalidBackend extends Backend {
  16. /** @var string Invalid backend id */
  17. private $invalidId;
  18. /**
  19. * Constructs a new InvalidBackend with the id of the invalid backend
  20. * for display purposes
  21. *
  22. * @param string $invalidId id of the backend that did not exist
  23. */
  24. public function __construct($invalidId) {
  25. $this->invalidId = $invalidId;
  26. $this
  27. ->setIdentifier($invalidId)
  28. ->setStorageClass('\OC\Files\Storage\FailedStorage')
  29. ->setText('Unknown storage backend ' . $invalidId);
  30. }
  31. /**
  32. * Returns the invalid backend id
  33. *
  34. * @return string invalid backend id
  35. */
  36. public function getInvalidId() {
  37. return $this->invalidId;
  38. }
  39. /**
  40. * @return void
  41. */
  42. public function manipulateStorageConfig(StorageConfig &$storage, ?IUser $user = null) {
  43. $storage->setBackendOption('exception', new \Exception('Unknown storage backend "' . $this->invalidId . '"', StorageNotAvailableException::STATUS_ERROR));
  44. }
  45. }