@@ 202-229 (lines=28) @@ | ||
199 | * @return void |
|
200 | * @throws \Cake\Network\Exception\NotFoundException When plugin do not exists |
|
201 | */ |
|
202 | public function settings($pluginName) |
|
203 | { |
|
204 | $info = plugin($pluginName); |
|
205 | $this->loadModel('System.Plugins'); |
|
206 | $plugin = $this->Plugins->get($pluginName, ['flatten' => true]); |
|
207 | ||
208 | if (!$info->hasSettings || $info->isTheme) { |
|
209 | throw new NotFoundException(__d('system', 'The requested page was not found.')); |
|
210 | } |
|
211 | ||
212 | if ($this->request->data()) { |
|
213 | $plugin = $this->Plugins->patchEntity($plugin, $this->request->data(), ['entity' => $plugin]); |
|
214 | if (!$plugin->errors()) { |
|
215 | if ($this->Plugins->save($plugin)) { |
|
216 | $this->Flash->success(__d('system', 'Plugin settings saved!')); |
|
217 | $this->redirect($this->referer()); |
|
218 | } |
|
219 | } else { |
|
220 | $this->Flash->danger(__d('system', 'Plugin settings could not be saved.')); |
|
221 | } |
|
222 | } |
|
223 | ||
224 | $this->title(__d('system', 'Plugin’s Settings')); |
|
225 | $this->set(compact('plugin', 'info')); |
|
226 | $this->Breadcrumb |
|
227 | ->push('/admin/system/plugins') |
|
228 | ->push(__d('system', 'Settings for "{0}" plugin', $info->name), '#'); |
|
229 | } |
|
230 | } |
|
231 |
@@ 241-268 (lines=28) @@ | ||
238 | * @return void |
|
239 | * @throws \Cake\Network\Exception\NotFoundException When plugin do not exists |
|
240 | */ |
|
241 | public function settings($themeName) |
|
242 | { |
|
243 | $info = plugin($themeName); |
|
244 | $this->loadModel('System.Plugins'); |
|
245 | $theme = $this->Plugins->get($themeName, ['flatten' => true]); |
|
246 | ||
247 | if (!$info->hasSettings || !$info->isTheme) { |
|
248 | throw new NotFoundException(__d('system', 'The requested page was not found.')); |
|
249 | } |
|
250 | ||
251 | if ($this->request->data()) { |
|
252 | $theme = $this->Plugins->patchEntity($theme, $this->request->data(), ['entity' => $theme]); |
|
253 | if (!$theme->errors()) { |
|
254 | if ($this->Plugins->save($theme)) { |
|
255 | $this->Flash->success(__d('system', 'Theme settings saved!')); |
|
256 | $this->redirect($this->referer()); |
|
257 | } |
|
258 | } else { |
|
259 | $this->Flash->danger(__d('system', 'Theme settings could not be saved.')); |
|
260 | } |
|
261 | } |
|
262 | ||
263 | $this->title(__d('system', 'Theme’s Settings')); |
|
264 | $this->set(compact('info', 'theme')); |
|
265 | $this->Breadcrumb |
|
266 | ->push('/admin/system/themes') |
|
267 | ->push(__d('system', 'Settings for {0} theme', $info->name), '#'); |
|
268 | } |
|
269 | } |
|
270 |