| Conditions | 2 |
| Paths | 2 |
| Total Lines | 26 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 24 | public function actionSaveSettings() |
||
| 25 | { |
||
| 26 | $this->requirePostRequest(); |
||
| 27 | $settings = Craft::$app->getRequest()->getBodyParam('settings'); |
||
| 28 | $message = Craft::t('enupal-socializer','Settings saved.'); |
||
| 29 | |||
| 30 | $plugin = Socializer::$app->settings->getPlugin(); |
||
| 31 | $settingsModel = $plugin->getSettings(); |
||
| 32 | |||
| 33 | $settingsModel->setAttributes($settings, false); |
||
| 34 | |||
| 35 | if (!Socializer::$app->settings->saveSettings($settingsModel)) { |
||
|
|
|||
| 36 | |||
| 37 | Craft::$app->getSession()->setError(Craft::t('enupal-socializer','Couldn’t save settings.')); |
||
| 38 | |||
| 39 | // Send the settings back to the template |
||
| 40 | Craft::$app->getUrlManager()->setRouteParams([ |
||
| 41 | 'settings' => $settingsModel |
||
| 42 | ]); |
||
| 43 | |||
| 44 | return null; |
||
| 45 | } |
||
| 46 | |||
| 47 | Craft::$app->getSession()->setNotice($message); |
||
| 48 | |||
| 49 | return $this->redirectToPostedUrl(); |
||
| 50 | } |
||
| 52 |