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 +--------------------------------------------------------------------+
13 namespace Civi\Api4\Action\Setting
;
15 use Civi\Api4\Generic\Result
;
18 * Revert one or more CiviCRM settings to their default value.
20 * @method array getSelect
21 * @method $this setSelect(array $settingNames) Set settings to be reverted
23 class Revert
extends AbstractSettingAction
{
26 * Names of settings to revert
31 protected $select = [];
34 * @param \Civi\Api4\Generic\Result $result
35 * @param \Civi\Core\SettingsBag $settingsBag
40 protected function processSettings(Result
$result, $settingsBag, $meta, $domain) {
41 foreach ($this->select
as $name) {
42 $settingsBag->revert($name);
45 'value' => $settingsBag->get($name),
46 'domain_id' => $domain,
49 foreach ($result as $name => &$setting) {
50 if (isset($setting['value']) && !empty($meta[$name]['serialize'])) {
51 $setting['value'] = \CRM_Core_DAO
::unSerializeField($setting['value'], $meta[$name]['serialize']);
57 * Add one or more settings to be reverted
58 * @param string ...$settingNames
61 public function addSelect(string ...$settingNames) {
62 $this->select
= array_merge($this->select
, $settingNames);