1 | <?php |
||
2 | /** |
||
3 | * @link https://dukt.net/social/ |
||
4 | * @copyright Copyright (c) Dukt |
||
5 | * @license https://github.com/dukt/social/blob/v2/LICENSE.md |
||
6 | */ |
||
7 | |||
8 | namespace dukt\social\controllers; |
||
9 | |||
10 | use Craft; |
||
11 | use craft\web\Controller; |
||
12 | use dukt\social\Plugin; |
||
13 | use yii\web\Response; |
||
14 | |||
15 | /** |
||
16 | * The SettingsController class is a controller that handles various settings related tasks. |
||
17 | * |
||
18 | * Note that all actions in the controller require an authenticated Craft session via [[allowAnonymous]]. |
||
19 | * |
||
20 | * @author Dukt <[email protected]> |
||
21 | * @since 1.0 |
||
22 | */ |
||
23 | class SettingsController extends BaseController |
||
24 | { |
||
25 | // Public Methods |
||
26 | // ========================================================================= |
||
27 | |||
28 | /** |
||
29 | * General settings. |
||
30 | * |
||
31 | * @return Response |
||
32 | * @throws \yii\base\InvalidConfigException |
||
33 | */ |
||
34 | public function actionSettings(): Response |
||
35 | { |
||
36 | $variables = []; |
||
37 | if (Craft::$app->getEdition() !== Craft::Pro) { |
||
38 | return $this->renderTemplate('social/settings/_pro-requirement'); |
||
39 | } |
||
40 | |||
41 | $plugin = Craft::$app->getPlugins()->getPlugin('social'); |
||
42 | $variables['settings'] = $plugin->getSettings(); |
||
43 | |||
44 | $accounts = Plugin::getInstance()->getLoginAccounts()->getLoginAccounts(); |
||
45 | $variables['totalAccounts'] = count((array) $accounts); |
||
46 | |||
47 | return $this->renderTemplate('social/settings/settings', $variables); |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * Saves the settings. |
||
52 | * |
||
53 | * @return null|Response |
||
54 | * @throws \craft\errors\MissingComponentException |
||
55 | * @throws \yii\web\BadRequestHttpException |
||
56 | */ |
||
57 | public function actionSaveSettings() |
||
58 | { |
||
59 | $this->requirePostRequest(); |
||
60 | $settings = Craft::$app->getRequest()->getBodyParam('settings', []); |
||
61 | $plugin = Craft::$app->getPlugins()->getPlugin('social'); |
||
62 | |||
63 | if ($plugin === null) { |
||
64 | throw new NotFoundHttpException('Plugin not found'); |
||
0 ignored issues
–
show
|
|||
65 | } |
||
66 | |||
67 | if (!Plugin::getInstance()->savePluginSettings($settings, $plugin)) { |
||
68 | Craft::$app->getSession()->setError(Craft::t('app', 'Couldn’t save plugin settings.')); |
||
69 | |||
70 | // Send the plugin back to the template |
||
71 | Craft::$app->getUrlManager()->setRouteParams([ |
||
72 | 'plugin' => $plugin |
||
73 | ]); |
||
74 | |||
75 | return null; |
||
76 | } |
||
77 | |||
78 | Craft::$app->getSession()->setNotice(Craft::t('app', 'Plugin settings saved.')); |
||
79 | |||
80 | return $this->redirectToPostedUrl(); |
||
81 | } |
||
82 | } |
||
83 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths