Override config options with the given values (eg. user prefs)

@param array $prefs Hash array with config props to merge over
779120
public function merge($prefs)
    {
        $prefs = $this->fix_legacy_props($prefs);
        $this->prop = array_merge($this->prop, $prefs, $this->userprefs);
    }
61531
public function configure(array $properties)
    {
        foreach ($properties as $name => $value) {
            $methodName = 'set' . ucfirst(strtolower($name));
            if (method_exists($this, $methodName)) {
                $this->$methodName($value);
            }
        }
    }
25175
private function mergeConfigs(array $first, array $second)
    {
        foreach ($second as $name => $value) {
            if (0 === strpos($name, 'override~')) {
                $name = preg_replace('/^override~/', '', $name);

                if (!array_key_exists($name, $first)) {
                    $this->logger->warning(sprintf('Unable to find parameter "%s" for overriding.', $name));

                    continue;
                }
                if (!is_array($first[$name])) {
                    throw new ConfigurationException(
                        sprintf('Unable to override parameter "%s": only array parameters can be overridden.', $name)
                    );
                }

                $first[$name] = $second['override~'.$name];

                continue;
            }
            if (0 === strpos($name, 'remove~')) {
                $name = preg_replace('/^remove~/', '', $name);

                if (!array_key_exists($name, $first)) {
                    $this->logger->warning(sprintf('Unable to find parameter "%s" for removal.', $name));

                    continue;
                }

                unset($first[$name]);

                continue;
            }

            preg_match('/^(after|before)~(.*)~(.*)$/', $name, $matches);

            if (4 === count($matches)) {
                list(, $position, $target, $name) = $matches;

                if (!array_key_exists($target, $first)) {
                    $this->logger->warning(sprintf('Unable to find parameter "%s" to place %s it.', $target, $position));

                    $first[$name] = $value;

                    continue;
                }

                $replacement = [];

                foreach ($first as $n => $v) {
                    if ('before' === $position && $n === $target) {
                        $replacement[$name] = $value;
                    }

                    $replacement[$n] = $v;

                    if ('after' === $position && $n === $target) {
                        $replacement[$name] = $value;
                    }
                }

                $first = $replacement;

                continue;
            }
            if (!array_key_exists($name, $first)) {
                $first[$name] = $value;

                continue;
            }
            if (!is_array($first[$name]) || !is_array($second[$name])) {
                $first[$name] = $second[$name];

                continue;
            }
            if ($this->isIndexed($first[$name]) && $this->isIndexed($second[$name])) {
                $first[$name] = array_merge($first[$name], $second[$name]);

                continue;
            }

            $first[$name] = $this->mergeConfigs($first[$name], $second[$name]);
        }

        return $first;
    }
294658
public function injectSettings(array $settings)
    {
        if (isset($settings['security']['authentication']['authenticationStrategy'])) {
            $authenticationStrategyName = $settings['security']['authentication']['authenticationStrategy'];
            switch ($authenticationStrategyName) {
                case 'allTokens':
                    $this->authenticationStrategy = self::AUTHENTICATE_ALL_TOKENS;
                    break;
                case 'oneToken':
                    $this->authenticationStrategy = self::AUTHENTICATE_ONE_TOKEN;
                    break;
                case 'atLeastOneToken':
                    $this->authenticationStrategy = self::AUTHENTICATE_AT_LEAST_ONE_TOKEN;
                    break;
                case 'anyToken':
                    $this->authenticationStrategy = self::AUTHENTICATE_ANY_TOKEN;
                    break;
                default:
                    throw new Exception('Invalid setting "' . $authenticationStrategyName . '" for security.authentication.authenticationStrategy', 1291043022);
            }
        }

        if (isset($settings['security']['csrf']['csrfStrategy'])) {
            $csrfStrategyName = $settings['security']['csrf']['csrfStrategy'];
            switch ($csrfStrategyName) {
                case 'onePerRequest':
                    $this->csrfProtectionStrategy = self::CSRF_ONE_PER_REQUEST;
                    break;
                case 'onePerSession':
                    $this->csrfProtectionStrategy = self::CSRF_ONE_PER_SESSION;
                    break;
                case 'onePerUri':
                    $this->csrfProtectionStrategy = self::CSRF_ONE_PER_URI;
                    break;
                default:
                    throw new Exception('Invalid setting "' . $csrfStrategyName . '" for security.csrf.csrfStrategy', 1291043024);
            }
        }
    }
861180
protected function set_prefs($prefs)
    {
        // set preferences
        if (is_array($prefs)) {
            $this->prefs = $prefs;
        }

        // set auth method
        if (!empty($this->prefs['auth_type'])) {
            $this->prefs['auth_type'] = strtoupper($this->prefs['auth_type']);
        }
        else {
            $this->prefs['auth_type'] = 'CHECK';
        }

        // disabled capabilities
        if (!empty($this->prefs['disabled_caps'])) {
            $this->prefs['disabled_caps'] = array_map('strtoupper', (array)$this->prefs['disabled_caps']);
        }

        // additional message flags
        if (!empty($this->prefs['message_flags'])) {
            $this->flags = array_merge($this->flags, $this->prefs['message_flags']);
            unset($this->prefs['message_flags']);
        }
    }
1040710
public function setProperties(array $properties)
    {
        if (isset($properties[ 'presets' ])) {
            $this->setPresets($properties[ 'presets' ]);

            unset($properties[ 'presets' ]);
        }

        $this->properties = $properties;

        return $this;
    }
1105921
public function config(array $configs)
    {
        foreach($configs as $key => $value)
        {
            if (property_exists($this, $key))
            {
                $this->$key = $value;
            }
        }
    }
1218878
public function changeConfigs(array $configs)
    {
        foreach ($configs as $config) {
            $config = array_merge($this->defaultConfig, $config);          
            if ($this->isValidConfig($config)) {
                $this->changeConfig($config['path'], $config['value'], $config['scope_type'], $config['scope_code']);
            }
        }

        $this->cache->clean();
    }
1010563
public function setConfigs(array $args) {
        if (!is_array(current($args))) {
            $args = [
                $this->currentName => $args
            ];
        }
        foreach ($args as $key => $item) {
            if (array_key_exists($key, $this->configs)) {
                $this->configs[$key] = array_merge($this->configs[$key], $item);
            } else {
                $this->configs[$key] = $item;
            }
        }
        return $this;
    }
548470
public static function configureWithPreset($preset, $settings) {
        // Load from JSON file if filename provided
        if (is_string($settings) && is_file($settings)) {
            throw new Maestrano_Config_Error("Metadata files are not accepted anymore, please use the Developer Platform");
        }

        // Ensure preset is initialized
        if (!array_key_exists($preset, self::$config) || is_null(self::$config[$preset])) {
            self::$config[$preset] = array();
        }

        //-------------------------------
        // App Config
        //-------------------------------
        if (array_key_exists('nid', $settings)) {
            self::$config[$preset]['nid'] = $settings['nid'];
        }

        if (array_key_exists('marketplace', $settings)) {
            self::$config[$preset]['marketplace'] = $settings['marketplace'];
        }

        if (array_key_exists('environment', $settings)) {
            self::$config[$preset]['environment'] = $settings['environment'];
        }

        if (array_key_exists('app', $settings) && array_key_exists('host', $settings['app'])) {
            self::$config[$preset]['app.host'] = $settings['app']['host'];
        }

        if (array_key_exists('app', $settings) && array_key_exists('synchronization_start_path', $settings['app'])) {
            self::$config[$preset]['app.synchronization_start_path'] = $settings['app']['synchronization_start_path'];
        }

        if (array_key_exists('app', $settings) && array_key_exists('synchronization_toggle_path', $settings['app'])) {
            self::$config[$preset]['app.synchronization_toggle_path'] = $settings['app']['synchronization_toggle_path'];
        }

        if (array_key_exists('app', $settings) && array_key_exists('synchronization_status_path', $settings['app'])) {
            self::$config[$preset]['app.synchronization_status_path'] = $settings['app']['synchronization_status_path'];
        }

        //-------------------------------
        // API Config
        //-------------------------------
        if (array_key_exists('api', $settings) && array_key_exists('id', $settings['api'])) {
            self::$config[$preset]['api.id'] = $settings['api']['id'];
        }

        if (array_key_exists('api', $settings) && array_key_exists('key', $settings['api'])) {
            self::$config[$preset]['api.key'] = $settings['api']['key'];
        }

        if (array_key_exists('api', $settings) && array_key_exists('host', $settings['api'])) {
            self::$config[$preset]['api.host'] = $settings['api']['host'];
        }

        if (array_key_exists('api', $settings) && array_key_exists('base', $settings['api'])) {
            self::$config[$preset]['api.base'] = $settings['api']['base'];
        }

        // Get lang/platform version
        self::$config[$preset]['api.version'] = Maestrano::VERSION;
        self::$config[$preset]['api.lang'] = 'php';
        self::$config[$preset]['api.lang_version'] = phpversion() . " " . php_uname();

        // Build api.token from api.id and api.key
        self::$config[$preset]['api.token'] = self::$config[$preset]['api.id'] . ":" . self::$config[$preset]['api.key'];

        //-------------------------------
        // SSO Config
        //-------------------------------
        if (array_key_exists('sso', $settings) && array_key_exists('idm', $settings['sso'])) {
            self::$config[$preset]['sso.idm'] = $settings['sso']['idm'];
        }

        if (array_key_exists('sso', $settings) && array_key_exists('init_path', $settings['sso'])) {
            self::$config[$preset]['sso.init_path'] = $settings['sso']['init_path'];
        }

        if (array_key_exists('sso', $settings) && array_key_exists('consume_path', $settings['sso'])) {
            self::$config[$preset]['sso.consume_path'] = $settings['sso']['consume_path'];
        }

        if (array_key_exists('sso', $settings) && array_key_exists('idp', $settings['sso'])) {
            self::$config[$preset]['sso.idp'] = $settings['sso']['idp'];
        }

        if (array_key_exists('sso', $settings) && array_key_exists('x509_fingerprint', $settings['sso'])) {
            self::$config[$preset]['sso.x509_fingerprint'] = $settings['sso']['x509_fingerprint'];
        }

        if (array_key_exists('sso', $settings) && array_key_exists('x509_certificate', $settings['sso'])) {
            self::$config[$preset]['sso.x509_certificate'] = $settings['sso']['x509_certificate'];
        }

        //-------------------------------
        // Connec! Config
        //-------------------------------
        if (array_key_exists('connec', $settings) && array_key_exists('host', $settings['connec'])) {
            self::$config[$preset]['connec.host'] = $settings['connec']['host'];
        }

        if (array_key_exists('connec', $settings) && array_key_exists('base_path', $settings['connec'])) {
            self::$config[$preset]['connec.base_path'] = $settings['connec']['base_path'];
        }

        if (array_key_exists('connec', $settings) && array_key_exists('timeout', $settings['connec'])) {
            self::$config[$preset]['connec.timeout'] = $settings['connec']['timeout'];
        }

        //-------------------------------
        // Webhook Config - Account
        //-------------------------------
        if (array_key_exists('webhooks', $settings)
            && array_key_exists('account', $settings['webhooks'])
            && array_key_exists('group_path', $settings['webhooks']['account'])) {
            self::$config[$preset]['webhooks.account.group_path'] = $settings['webhooks']['account']['group_path'];
        }

        if (array_key_exists('webhooks', $settings)
            && array_key_exists('account', $settings['webhooks'])
            && array_key_exists('group_user_path', $settings['webhooks']['account'])) {
            self::$config[$preset]['webhooks.account.group_user_path'] = $settings['webhooks']['account']['group_user_path'];
        }

        //-------------------------------
        // Webhook Config - Connec
        //-------------------------------
        if (array_key_exists('webhooks', $settings)
            && array_key_exists('connec', $settings['webhooks'])
            && array_key_exists('external_ids', $settings['webhooks']['connec'])) {
            self::$config[$preset]['webhooks.connec.external_ids'] = $settings['webhooks']['connec']['external_ids'];
        }

        if (array_key_exists('webhooks', $settings)
            && array_key_exists('connec', $settings['webhooks'])
            && array_key_exists('initialization_path', $settings['webhooks']['connec'])) {
            self::$config[$preset]['webhooks.connec.initialization_path'] = $settings['webhooks']['connec']['initialization_path'];
        }

        if (array_key_exists('webhooks', $settings)
            && array_key_exists('connec', $settings['webhooks'])
            && array_key_exists('notification_path', $settings['webhooks']['connec'])) {
            self::$config[$preset]['webhooks.connec.notification_path'] = $settings['webhooks']['connec']['notification_path'];
        }

        return true;
    }
1292554
public static function setOptions(array $userOptions = array())
    {
        // set default options on first run only (before applying user settings)
        if (!self::$_defaultOptionsSet) {
            foreach (self::$_defaultOptions as $defaultOptionName => $defaultOptionValue) {
                if (isset(self::$_defaultOptions[$defaultOptionName])) {
                    @ini_set("session.$defaultOptionName", $defaultOptionValue);
                }
            }

            self::$_defaultOptionsSet = true;
        }

        // set the options the user has requested to set
        foreach ($userOptions as $userOptionName => $userOptionValue) {

            $userOptionName = strtolower($userOptionName);

            // set the ini based values
            if (array_key_exists($userOptionName, self::$_defaultOptions)) {
                @ini_set("session.$userOptionName", $userOptionValue);
            }
            elseif (isset(self::$_localOptions[$userOptionName])) {
                self::${self::$_localOptions[$userOptionName]} = $userOptionValue;
            }
            else {
                /** @see Zend_Session_Exception */
                // require_once 'Zend/Session/Exception.php';
                throw new Zend_Session_Exception("Unknown option: $userOptionName = $userOptionValue");
            }
        }
    }
254810
protected function setOptions(array $options = []): void
    {
        $this->options = $options;
        $this->configName = empty($options['cacheConfig']) ? static::DEFAULT_CONFIG : (string)$options['cacheConfig'];
        $this->skipCache = empty($this->options['cacheSkip']) ? false : (bool)$this->options['cacheSkip'];
    }
243646
public function alterFormValues(array $formValues)
    {
        foreach ($this->getMeta() as $key => $fieldMeta) {
            /** @var \stdClass $fieldMeta */
            if ($fieldMeta->type === 'checkbox') {
                if (isset($formValues[$key])) {
                    $prestaShopName = $fieldMeta->collection . '_' . $key;
                    $formValues[$prestaShopName] = $formValues[$key];
                }
            }
        }
        return $formValues;
    }
92283
protected function setDefaultConfig($args)
    {
        if (!current($this->config)) {
            $this->config = $this->toArray($args);
        }
    }
1203631
protected function initDefaults($defaults)
    {
        if (!$defaults) {
            return;
        }

        $defaults = $this->fetchParameters($defaults);
        $this->initDefaultsInConfigArray($defaults);
    }
579321
public function setProps($props = array())
    {
        $props = $this->moveShortcuts($props);
        $type = isset($props['attribs']['type']) ? $props['attribs']['type'] : null;
        $typeChanging = $type && (!isset($this->attribs['type']) || $type !== $this->attribs['type']);
        $propsType = $typeChanging && isset($this->defaultPropsType[$type])
            ? $this->defaultPropsType[$type]
            : array();
        $this->props = $this->mergeProps(array(
            $this->props,
            $propsType,
            $props,
        ));
        if (empty($this->props['attribs']['x-moz-errormessage']) && !empty($this->props['invalidReason'])) {
            $this->props['attribs']['x-moz-errormessage'] = $this->props['invalidReason'];
        }
        $this->attribs = &$this->props['attribs'];
        $this->getId();
        if (\in_array($type, array('checkbox','radio','select'))) {
            $this->normalizeCrs();
        } elseif ($type == 'submit' && empty($props['label']) && !empty($props['attribs']['value'])) {
            $props['label'] = $props['attribs']['value'];
        }
    }
973881
public function mergeUserOptions(array $options) {
    foreach ($options as $option=>$value)
      $this->_options[$option] = $value;
    return $this;
  }