mirror of
https://github.com/flarum/core.git
synced 2025-07-25 18:51:40 +02:00
Add ability to uninstall an extension
This commit is contained in:
37
framework/core/src/Api/Actions/Extensions/DeleteAction.php
Normal file
37
framework/core/src/Api/Actions/Extensions/DeleteAction.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php namespace Flarum\Api\Actions\Extensions;
|
||||
|
||||
use Flarum\Api\Actions\DeleteAction as BaseDeleteAction;
|
||||
use Flarum\Api\Request;
|
||||
use Illuminate\Contracts\Bus\Dispatcher;
|
||||
use Flarum\Core\Exceptions\PermissionDeniedException;
|
||||
use Flarum\Support\ExtensionManager;
|
||||
|
||||
class DeleteAction extends BaseDeleteAction
|
||||
{
|
||||
protected $extensions;
|
||||
|
||||
public function __construct(ExtensionManager $extensions)
|
||||
{
|
||||
$this->extensions = $extensions;
|
||||
}
|
||||
|
||||
protected function delete(Request $request)
|
||||
{
|
||||
if (! $request->actor->isAdmin()) {
|
||||
throw new PermissionDeniedException;
|
||||
}
|
||||
|
||||
$name = $request->get('name');
|
||||
|
||||
$this->extensions->disable($name);
|
||||
$this->extensions->uninstall($name);
|
||||
|
||||
app('flarum.formatter')->flush();
|
||||
|
||||
$forum = app('Flarum\Forum\Actions\ClientAction');
|
||||
$forum->flushAssets();
|
||||
|
||||
$admin = app('Flarum\Admin\Actions\ClientAction');
|
||||
$admin->flushAssets();
|
||||
}
|
||||
}
|
@@ -306,6 +306,13 @@ class ApiServiceProvider extends ServiceProvider
|
||||
$this->action('Flarum\Api\Actions\Extensions\UpdateAction')
|
||||
);
|
||||
|
||||
// Uninstall an extension
|
||||
$routes->delete(
|
||||
'/extensions/{name}',
|
||||
'flarum.api.extensions.delete',
|
||||
$this->action('Flarum\Api\Actions\Extensions\DeleteAction')
|
||||
);
|
||||
|
||||
// Update config settings
|
||||
$routes->post(
|
||||
'/config',
|
||||
|
@@ -35,4 +35,9 @@ class DatabaseSettingsRepository implements SettingsRepository
|
||||
|
||||
$query->$method(compact('key', 'value'));
|
||||
}
|
||||
|
||||
public function delete($key)
|
||||
{
|
||||
$this->database->table('config')->where('key', $key)->delete();
|
||||
}
|
||||
}
|
||||
|
@@ -42,4 +42,11 @@ class MemoryCacheSettingsRepository implements SettingsRepository
|
||||
|
||||
$this->inner->set($key, $value);
|
||||
}
|
||||
|
||||
public function delete($key)
|
||||
{
|
||||
unset($this->cache[$key]);
|
||||
|
||||
$this->inner->delete($key);
|
||||
}
|
||||
}
|
||||
|
@@ -9,4 +9,6 @@ interface SettingsRepository
|
||||
public function get($key, $default = null);
|
||||
|
||||
public function set($key, $value);
|
||||
|
||||
public function delete($key);
|
||||
}
|
||||
|
Reference in New Issue
Block a user