InvalidBackend.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. /**
  17. * Constructs a new InvalidBackend with the id of the invalid backend
  18. * for display purposes
  19. *
  20. * @param string $invalidId id of the backend that did not exist
  21. */
  22. public function __construct(
  23. private $invalidId,
  24. ) {
  25. $this
  26. ->setIdentifier($this->invalidId)
  27. ->setStorageClass('\OC\Files\Storage\FailedStorage')
  28. ->setText('Unknown storage backend ' . $this->invalidId);
  29. }
  30. /**
  31. * Returns the invalid backend id
  32. *
  33. * @return string invalid backend id
  34. */
  35. public function getInvalidId() {
  36. return $this->invalidId;
  37. }
  38. /**
  39. * @return void
  40. */
  41. public function manipulateStorageConfig(StorageConfig &$storage, ?IUser $user = null) {
  42. $storage->setBackendOption('exception', new \Exception('Unknown storage backend "' . $this->invalidId . '"', StorageNotAvailableException::STATUS_ERROR));
  43. }
  44. }