public function uninstall($themeName)
    {
        $theme = plugin($themeName); // throws
        if (!in_array($themeName, [option('front_theme'), option('back_theme')])) {
            if (!$theme->requiredBy()->isEmpty()) {
                $this->Flash->danger(__d('system', 'You cannot remove this theme!'));
            } else {
                $task = (bool)WebShellDispatcher::run("Installer.plugins uninstall -p {$theme->name}");
                if ($task) {
                    $this->Flash->success(__d('system', 'Theme successfully removed!'));
                } else {
                    $this->Flash->set(__d('system', 'Theme could not be removed'), [
                        'element' => 'System.installer_errors',
                        'params' => ['errors' => WebShellDispatcher::output()],
                    ]);
                }
            }
        } else {
            $this->Flash->danger(__d('system', 'This theme cannot be removed as it is currently being used.'));
        }

        $this->title(__d('system', 'Uninstall Theme'));
        $this->redirect($this->referer());
    }