mirror of
https://github.com/friendica/friendica
synced 2025-04-26 09:10:15 +00:00
Introduce InvalidClassStorageException and adapt the code for it
This commit is contained in:
parent
b798ca2da6
commit
c17bc55158
9 changed files with 259 additions and 267 deletions
|
@ -23,6 +23,7 @@ namespace Friendica\Console;
|
|||
|
||||
use Asika\SimpleConsole\CommandArgsException;
|
||||
use Friendica\Core\StorageManager;
|
||||
use Friendica\Model\Storage\ReferenceStorageException;
|
||||
use Friendica\Model\Storage\StorageException;
|
||||
|
||||
/**
|
||||
|
@ -127,23 +128,23 @@ HELP;
|
|||
|
||||
protected function doSet()
|
||||
{
|
||||
if (count($this->args) !== 2) {
|
||||
if (count($this->args) !== 2 || empty($this->args[1])) {
|
||||
throw new CommandArgsException('Invalid arguments');
|
||||
}
|
||||
|
||||
$name = $this->args[1];
|
||||
$class = $this->storageManager->getWritableStorageByName($name);
|
||||
$name = $this->args[1];
|
||||
try {
|
||||
$class = $this->storageManager->getWritableStorageByName($name);
|
||||
|
||||
if (is_null($class)) {
|
||||
if (!$this->storageManager->setBackend($class)) {
|
||||
$this->out($class . ' is not a valid backend storage class.');
|
||||
return -1;
|
||||
}
|
||||
} catch (ReferenceStorageException $exception) {
|
||||
$this->out($name . ' is not a registered backend.');
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!$this->storageManager->setBackend($class)) {
|
||||
$this->out($class . ' is not a valid backend storage class.');
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue