mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-04 20:36:03 +01:00
Complete remove plugin task. Handle failure.
This commit is contained in:
@@ -263,30 +263,27 @@ class AdminController
|
|||||||
*/
|
*/
|
||||||
protected function taskRemovePlugin()
|
protected function taskRemovePlugin()
|
||||||
{
|
{
|
||||||
|
if (!$this->authorizeTask('uninstall plugin', ['admin.plugin', 'admin.super'])) {
|
||||||
|
$this->admin->json_response = ['status' => 'error', 'message' => 'Unauthorized'];
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$data = $this->post;
|
$data = $this->post;
|
||||||
$slug = isset($data['plugin']) ? $data['plugin'] : '';
|
$plugin = isset($data['plugin']) ? $data['plugin'] : '';
|
||||||
|
|
||||||
error_log("Plugin $slug Removed");
|
require_once __DIR__ . '/gpm.php';
|
||||||
|
|
||||||
//TODO: remove the plugin, return error if fail
|
|
||||||
|
|
||||||
$this->admin->json_response = ['status' => 'success'];
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle getting a plugin dependencies
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
protected function taskGetPluginDependencies()
|
|
||||||
{
|
|
||||||
$plugin = $this->grav['uri']->param('plugin');
|
|
||||||
error_log("Get dependencies of plugin $plugin");
|
|
||||||
|
|
||||||
$dependencies = $this->admin->dependenciesThatCanBeRemovedWhenRemoving($plugin);
|
$dependencies = $this->admin->dependenciesThatCanBeRemovedWhenRemoving($plugin);
|
||||||
$this->admin->json_response = ['status' => 'success', 'dependencies' => $dependencies];
|
|
||||||
|
//TODO: uncomment to actually remove
|
||||||
|
$result = true;
|
||||||
|
// $result = \Grav\Plugin\Admin\Gpm::uninstall($plugin, []);
|
||||||
|
|
||||||
|
if ($result) {
|
||||||
|
$this->admin->json_response = ['status' => 'success', 'dependencies' => $dependencies, 'message' => $this->admin->translate('PLUGIN_ADMIN.UNINSTALL_SUCCESSFUL')];
|
||||||
|
} else {
|
||||||
|
$this->admin->json_response = ['status' => 'error', 'message' => $this->admin->translate('PLUGIN_ADMIN.UNINSTALL_FAILED')];
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user