2016-11-03 07:14:44 -04:00
|
|
|
<?php
|
|
|
|
|
/**
|
2024-06-06 03:55:47 -04:00
|
|
|
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud GmbH.
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2016-11-03 07:14:44 -04:00
|
|
|
*/
|
|
|
|
|
namespace OCA\Files_External\Lib\Backend;
|
|
|
|
|
|
2017-09-01 09:34:32 -04:00
|
|
|
use OCA\Files_External\Lib\StorageConfig;
|
2017-09-01 09:52:17 -04:00
|
|
|
use OCP\Files\StorageNotAvailableException;
|
2017-09-01 09:34:32 -04:00
|
|
|
use OCP\IUser;
|
|
|
|
|
|
2016-11-03 07:14:44 -04:00
|
|
|
/**
|
|
|
|
|
* Invalid storage backend representing a backend
|
|
|
|
|
* that could not be resolved
|
|
|
|
|
*/
|
|
|
|
|
class InvalidBackend extends Backend {
|
|
|
|
|
|
|
|
|
|
/** @var string Invalid backend id */
|
|
|
|
|
private $invalidId;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructs a new InvalidBackend with the id of the invalid backend
|
|
|
|
|
* for display purposes
|
|
|
|
|
*
|
|
|
|
|
* @param string $invalidId id of the backend that did not exist
|
|
|
|
|
*/
|
2020-04-10 10:51:06 -04:00
|
|
|
public function __construct($invalidId) {
|
2016-11-03 07:14:44 -04:00
|
|
|
$this->invalidId = $invalidId;
|
|
|
|
|
$this
|
|
|
|
|
->setIdentifier($invalidId)
|
2017-08-29 07:37:13 -04:00
|
|
|
->setStorageClass('\OC\Files\Storage\FailedStorage')
|
2017-09-01 09:34:32 -04:00
|
|
|
->setText('Unknown storage backend ' . $invalidId);
|
2016-11-03 07:14:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the invalid backend id
|
|
|
|
|
*
|
|
|
|
|
* @return string invalid backend id
|
|
|
|
|
*/
|
|
|
|
|
public function getInvalidId() {
|
|
|
|
|
return $this->invalidId;
|
|
|
|
|
}
|
2017-09-01 09:34:32 -04:00
|
|
|
|
2024-03-28 12:15:01 -04:00
|
|
|
/**
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
2024-03-28 11:13:19 -04:00
|
|
|
public function manipulateStorageConfig(StorageConfig &$storage, ?IUser $user = null) {
|
2017-09-01 09:52:17 -04:00
|
|
|
$storage->setBackendOption('exception', new \Exception('Unknown storage backend "' . $this->invalidId . '"', StorageNotAvailableException::STATUS_ERROR));
|
2017-09-01 09:34:32 -04:00
|
|
|
}
|
2016-11-03 07:14:44 -04:00
|
|
|
}
|