mirror of
https://github.com/flarum/core.git
synced 2025-08-13 11:54:32 +02:00
Extension state exceptions
This commit is contained in:
@@ -9,6 +9,7 @@ namespace SychO\PackageManager\Command;
|
||||
use Composer\Console\Application;
|
||||
use Flarum\Extension\ExtensionManager;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use SychO\PackageManager\Exception\ExtensionNotInstalledException;
|
||||
use SychO\PackageManager\Extension\Event\Removed;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
@@ -48,7 +49,7 @@ class RemoveExtensionHandler
|
||||
$extension = $this->extensions->getExtension($command->extensionId);
|
||||
|
||||
if (empty($extension)) {
|
||||
// ... exception
|
||||
throw new ExtensionNotInstalledException($command->extensionId);
|
||||
}
|
||||
|
||||
$output = new BufferedOutput();
|
||||
|
@@ -10,6 +10,7 @@ use Composer\Console\Application;
|
||||
use Flarum\Extension\ExtensionManager;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use SychO\PackageManager\Exception\ComposerRequireFailedException;
|
||||
use SychO\PackageManager\Exception\ExtensionAlreadyInstalledException;
|
||||
use SychO\PackageManager\Extension\Event\Installed;
|
||||
use SychO\PackageManager\Extension\ExtensionUtils;
|
||||
use SychO\PackageManager\RequirePackageValidator;
|
||||
@@ -60,7 +61,7 @@ class RequireExtensionHandler
|
||||
$extension = $this->extensions->getExtension($extensionId);
|
||||
|
||||
if (! empty($extension)) {
|
||||
// ... exception
|
||||
throw new ExtensionAlreadyInstalledException($extension);
|
||||
}
|
||||
|
||||
$output = new BufferedOutput();
|
||||
|
@@ -11,6 +11,7 @@ use Flarum\Extension\ExtensionManager;
|
||||
use Flarum\Settings\SettingsRepositoryInterface;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use SychO\PackageManager\Exception\ComposerUpdateFailedException;
|
||||
use SychO\PackageManager\Exception\ExtensionNotInstalledException;
|
||||
use SychO\PackageManager\Extension\Event\Updated;
|
||||
use SychO\PackageManager\UpdateExtensionValidator;
|
||||
use SychO\PackageManager\LastUpdateCheck;
|
||||
@@ -66,7 +67,7 @@ class UpdateExtensionHandler
|
||||
$extension = $this->extensions->getExtension($command->extensionId);
|
||||
|
||||
if (empty($extension)) {
|
||||
// ... exception
|
||||
throw new ExtensionNotInstalledException($command->extensionId);
|
||||
}
|
||||
|
||||
$output = new BufferedOutput();
|
||||
|
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
namespace SychO\PackageManager\Exception;
|
||||
|
||||
use Exception;
|
||||
use Flarum\Extension\Extension;
|
||||
use Flarum\Foundation\KnownError;
|
||||
|
||||
class ExtensionAlreadyInstalledException extends Exception implements KnownError
|
||||
{
|
||||
public function __construct(Extension $extension)
|
||||
{
|
||||
parent::__construct("Extension {$extension->getTitle()} is already installed.");
|
||||
}
|
||||
|
||||
public function getType(): string
|
||||
{
|
||||
return 'extension_already_installed';
|
||||
}
|
||||
}
|
23
extensions/package-manager/src/Exception/ExtensionNotInstalledException.php
Executable file
23
extensions/package-manager/src/Exception/ExtensionNotInstalledException.php
Executable file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
namespace SychO\PackageManager\Exception;
|
||||
|
||||
use Exception;
|
||||
use Flarum\Foundation\KnownError;
|
||||
|
||||
class ExtensionNotInstalledException extends Exception implements KnownError
|
||||
{
|
||||
public function __construct(string $extensionId)
|
||||
{
|
||||
parent::__construct("Extension {$extensionId} is not installed.");
|
||||
}
|
||||
|
||||
public function getType(): string
|
||||
{
|
||||
return 'extension_not_installed';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user