. */ namespace SP\Modules\Web\Controllers\Plugin; use Exception; use SP\Core\Application; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; use SP\Domain\Plugin\PluginServiceInterface; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\ControllerBase; use SP\Modules\Web\Controllers\Traits\JsonTrait; use SP\Mvc\Controller\WebControllerHelper; /** * Class DisableController */ final class DisableController extends ControllerBase { use JsonTrait; private PluginServiceInterface $pluginService; public function __construct( Application $application, WebControllerHelper $webControllerHelper, PluginServiceInterface $pluginService ) { parent::__construct($application, $webControllerHelper); $this->checkLoggedIn(); $this->pluginService = $pluginService; } /** * disableAction * * @param int $id * * @return bool * @throws \JsonException */ public function disableAction(int $id): bool { try { $this->pluginService->toggleEnabled($id, false); $this->eventDispatcher->notifyEvent( 'edit.plugin.disable', new Event($this, EventMessage::factory()->addDescription(__u('Plugin disabled'))) ); return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Plugin disabled')); } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); return $this->returnJsonResponseException($e); } } }