Code Duplication    Length = 18-18 lines in 3 locations

plugins/System/src/Controller/Admin/PluginsController.php 3 locations

@@ 104-121 (lines=18) @@
101
     * @param string $pluginName Plugin's name
102
     * @return void Redirects to previous page
103
     */
104
    public function delete($pluginName)
105
    {
106
        $plugin = plugin($pluginName); // throws if not exists
107
        $task = (bool)WebShellDispatcher::run("Installer.plugins uninstall -p {$plugin->name}");
108
109
        if ($task) {
110
            $this->Flash->success(__d('system', 'Plugin was successfully removed!'));
111
        } else {
112
            $this->Flash->set(__d('system', 'Plugins could not be removed'), [
113
                'element' => 'System.installer_errors',
114
                'params' => ['errors' => WebShellDispatcher::output()],
115
            ]);
116
        }
117
118
        $this->title(__d('system', 'Uninstall Plugin'));
119
        header('Location:' . $this->referer());
120
        exit();
121
    }
122
123
    /**
124
     * Enables the given plugin.
@@ 129-146 (lines=18) @@
126
     * @param string $pluginName Plugin's name
127
     * @return void Redirects to previous page
128
     */
129
    public function enable($pluginName)
130
    {
131
        $plugin = plugin($pluginName);
132
        $task = (bool)WebShellDispatcher::run("Installer.plugins toggle -p {$plugin->name} -s enable");
133
134
        if ($task) {
135
            $this->Flash->success(__d('system', 'Plugin was successfully enabled!'));
136
        } else {
137
            $this->Flash->set(__d('system', 'Plugin could not be enabled'), [
138
                'element' => 'System.installer_errors',
139
                'params' => ['errors' => WebShellDispatcher::output()],
140
            ]);
141
        }
142
143
        $this->title(__d('system', 'Enable Plugin'));
144
        header('Location:' . $this->referer());
145
        exit();
146
    }
147
148
    /**
149
     * Disables the given plugin.
@@ 154-171 (lines=18) @@
151
     * @param string $pluginName Plugin's name
152
     * @return void Redirects to previous page
153
     */
154
    public function disable($pluginName)
155
    {
156
        $plugin = plugin($pluginName);
157
        $task = (bool)WebShellDispatcher::run("Installer.plugins toggle -p {$plugin->name} -s disable");
158
159
        if ($task) {
160
            $this->Flash->success(__d('system', 'Plugin was successfully disabled!'));
161
        } else {
162
            $this->Flash->set(__d('system', 'Plugin could not be disabled'), [
163
                'element' => 'System.installer_errors',
164
                'params' => ['errors' => WebShellDispatcher::output()],
165
            ]);
166
        }
167
168
        $this->title(__d('system', 'Disable Plugin'));
169
        header('Location:' . $this->referer());
170
        exit();
171
    }
172
173
    /**
174
     * Handles plugin's specifics settings.