4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC. All rights reserved. |
7 | This work is published under the GNU AGPLv3 license with some |
8 | permitted exceptions and without any warranty. For full license |
9 | and copyright information, see https://civicrm.org/licensing |
10 +--------------------------------------------------------------------+
16 * @copyright CiviCRM LLC https://civicrm.org/licensing
21 namespace Civi\Api4\Action\Setting
;
23 use Civi\Api4\Generic\Result
;
26 * Revert one or more CiviCRM settings to their default value.
28 * @method array getSelect
29 * @method $this setSelect(array $settingNames) Set settings to be reverted
31 class Revert
extends AbstractSettingAction
{
34 * Names of settings to revert
39 protected $select = [];
42 * @param \Civi\Api4\Generic\Result $result
43 * @param \Civi\Core\SettingsBag $settingsBag
48 protected function processSettings(Result
$result, $settingsBag, $meta, $domain) {
49 foreach ($this->select
as $name) {
50 $settingsBag->revert($name);
53 'value' => $settingsBag->get($name),
54 'domain_id' => $domain,
57 foreach ($result as $name => &$setting) {
58 if (isset($setting['value']) && !empty($meta[$name]['serialize'])) {
59 $setting['value'] = \CRM_Core_DAO
::unSerializeField($setting['value'], $meta[$name]['serialize']);
65 * Add one or more settings to be reverted
66 * @param string ...$settingNames
69 public function addSelect(string ...$settingNames) {
70 $this->select
= array_merge($this->select
, $settingNames);