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 * Set the value of one or more CiviCRM settings.
28 * @method array getValues
29 * @method $this setValues(array $value)
31 class Set
extends AbstractSettingAction
{
34 * Setting names/values to set.
39 protected $values = [];
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->values
as $name => $value) {
50 if (isset($value) && !empty($meta[$name]['serialize'])) {
51 $value = \CRM_Core_DAO
::serializeField($value, $meta[$name]['serialize']);
53 $settingsBag->set($name, $value);
56 'value' => $this->values
[$name],
57 'domain_id' => $domain,
63 * Add an item to the values array
64 * @param string $settingName
68 public function addValue($settingName, $value) {
69 $this->values
[$settingName] = $value;