| 1 | <?php |
||
| 24 | class UpdateSettings extends CreateModel |
||
| 25 | { |
||
| 26 | public $validBodyParams = [ |
||
| 27 | 'callbackUrlPath', |
||
| 28 | 'encryptStorageData', |
||
| 29 | 'autoPopulateTokenEnvironments', |
||
| 30 | 'applyProviderEnvironmentsToToken' |
||
| 31 | ]; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @inheritdoc |
||
| 35 | */ |
||
| 36 | public $statusCodeSuccess = 200; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @param Model $model |
||
| 40 | * @return bool |
||
| 41 | * @throws \Throwable |
||
| 42 | */ |
||
| 43 | protected function performAction(Model $model): bool |
||
| 44 | { |
||
| 45 | if (!$model instanceof Settings) { |
||
| 46 | throw new NotFoundHttpException(sprintf( |
||
| 47 | "Settings must be an instance of '%s', '%s' given.", |
||
| 48 | Settings::class, |
||
| 49 | get_class($model) |
||
| 50 | )); |
||
| 51 | } |
||
| 52 | |||
| 53 | return Craft::$app->getPlugins()->savePluginSettings( |
||
| 54 | Patron::getInstance(), |
||
| 55 | $model->toArray() |
||
| 56 | ); |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @inheritdoc |
||
| 61 | * @return Settings |
||
| 62 | */ |
||
| 63 | protected function newModel(array $config = []): Model |
||
| 67 | } |
||
| 68 |