Overload a config registry

@param   array   $settings
@return  void
162370
public static function overload(array $settings)
    {
        if (self::mustLoad()) {
            self::load();
        }
        foreach ($settings as $var=>$val) {
            self::set($var, $val);
        }
    }
847489
public function update(array $settings)
    {
        foreach ($settings as $key => $value) {
            $this->getSettingOrFail($key);
        }

        $this->backend->setSettings($settings);
    }
352810
protected function addModelSettings(array &$settings)
    {
        $empty = $this->util->getTranslated()->getEmptyDropdownArray();

        $settings['elementClass'] = 'Select';
        $settings['multiOptions'] = $empty + $this->util->getDbLookup()->getUserConsents();
    }
1137129
public function initialize(array $config)
    {
        parent::initialize($config);

        $this->setController($this->_registry->getController());

        $this->_registerFromConfigure();
    }
749937
public static function mergeWithDefaultSettings($settings)
    {
        if (empty($settings)) {
            return static::getDefaultSettings();
        }
        if (is_array($settings)) {
            return array_merge(static::getDefaultSettings(), $settings);
        }
        throw new Exception("Argument must be an array.");
    }
1243830
protected function connect(array $settings): void
  {
    $host     = $this->getSetting($settings, true, 'database', 'host');
    $user     = $this->getSetting($settings, true, 'database', 'user');
    $password = $this->getSetting($settings, true, 'database', 'password');
    $database = $this->getSetting($settings, true, 'database', 'database');

    MetadataDataLayer::setIo($this->io);
    MetadataDataLayer::connect($host, $user, $password, $database);
  }
1122833
public function initSettings(array $settings)
    {
        if (!isset($settings['tcp'])) {
            throw new \InvalidArgumentException('Tcp startup parameter is not configured，settings=' . \json_encode($settings));
        }

        if (!isset($settings['http'])) {
            throw new \InvalidArgumentException('HTTP startup parameters is not configured, settings=' . \json_encode($settings));
        }

        if (!isset($settings['server'])) {
            throw new \InvalidArgumentException('server startup parameters is not configured, settings=' . \json_encode($settings));
        }

        if (!isset($settings['setting'])) {
            throw new \InvalidArgumentException('"setting" parameters is not configured, settings=' . \json_encode($settings));
        }

        foreach ($settings['setting'] as $key => $value) {
            // path alias
            if ($value && \is_string($value) && $value[0] === '@') {
                $settings['setting'][$key] = App::getAlias($value);
            }
        }

        $this->setting = $settings['setting'];
        $this->tcpSetting = $settings['tcp'];
        $this->httpSetting = $settings['http'];
        $this->serverSetting = $settings['server'];

        // fix bug must to int
        if (isset($this->setting['task_ipc_mode'])) {
            $this->setting['task_ipc_mode'] = (int)$this->setting['task_ipc_mode'];
        }
        if (isset($this->setting['message_queue_key'])) {
            $this->setting['message_queue_key'] = (int)$this->setting['message_queue_key'];
        }
    }
1091805
public static function loadCmdLineArgs($settings)
    {
        $error = false;

        static $ktr = [
            '-' => '',
        ];

        foreach ($settings as $k => $v) {
            $k = strtolower(strtr($k, $ktr));

            if ($k === 'config') {
                $k = 'configfile';
            }

            if (($k === 'user') || ($k === 'group')) {
                if ($v === '') {
                    $v = null;
                }
            }
            if (isset(Daemon::$config->{$k})) {
                Daemon::$config->{$k}->setHumanValue($v);
                Daemon::$config->{$k}->source = 'cmdline';
            } else {
                Daemon::log('Unrecognized parameter \'' . $k . '\'');
                $error = true;
            }
        }

        return !$error;
    }
915016
public function injectSettings(array $settings) {
		if (isset($settings['server']['serviceBaseUri'])) {
			$this->serverServiceBaseUri = $settings['server']['serviceBaseUri'];
		}
		if (isset($settings['server']['keyPairFingerprint'])) {
			$this->serverKeyPairFingerprint = $settings['server']['keyPairFingerprint'];
		}
	}
264477
public function registerServices(array $userSettings = [])
    {
        $defaultSettings = $this->defaultSettings;

        $this['settings'] = function () use ($userSettings, $defaultSettings) {
            return new Collection(array_merge($defaultSettings, $userSettings));
        };

        $serviceProvider = new ServiceProvider();
        $serviceProvider->register($this);
    }
928422
public function injectSettings(array $settings): void
    {
        if (isset($settings['security']['authentication']['authenticationStrategy'])) {
            $authenticationStrategyName = $settings['security']['authentication']['authenticationStrategy'];
            switch ($authenticationStrategyName) {
                case 'allTokens':
                    $this->authenticationStrategy = Context::AUTHENTICATE_ALL_TOKENS;
                    break;
                case 'oneToken':
                    $this->authenticationStrategy = Context::AUTHENTICATE_ONE_TOKEN;
                    break;
                case 'atLeastOneToken':
                    $this->authenticationStrategy = Context::AUTHENTICATE_AT_LEAST_ONE_TOKEN;
                    break;
                case 'anyToken':
                    $this->authenticationStrategy = Context::AUTHENTICATE_ANY_TOKEN;
                    break;
                default:
                    throw new Exception('Invalid setting "' . $authenticationStrategyName . '" for security.authentication.authenticationStrategy', 1291043022);
            }
        }
    }
968284
protected function storeMiscSettings($settings)
    {
        if (isset($settings['set'])) {
            $this->set = $settings['set'];
        }
        if (isset($settings['metadataPrefix'])) {
            $this->metadataPrefix = $settings['metadataPrefix'];
        }
        if (isset($settings['dateGranularity'])) {
            $this->granularity = $settings['dateGranularity'];
        }
    }
233296
protected function addModelSettings(array &$settings)
    {
        $settings['elementClass']  = 'Date';
        $settings['dateFormat']    = $this->getDateFormat();
        $settings['storageFormat'] = $this->getStorageFormat();
        $settings['type']          = $this->type;
    }
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);
            }
        }
    }
1257984
public function settings(Array $settings = []) : Upload
    {
        foreach( $settings as $key => $val )
        {
            $this->settings[$key] = $val;
        }

        return $this;
    }
357292
public static function init($settings = null)
    {
        if (is_array($settings)) {
            //merging settings (and setting the global settings)
            //settings should be submitted via an array
            $settings = self::settings($settings);
        } else {
            $settings = self::settings();
        }

        if ($settings['enabled']) {
            $ssversion = self::subpackage_settings('ssversion');

            //Enabling calendars
            if (self::subpackage_enabled('calendars')) {
                if ($ssversion == '3.0') {
                    Object::add_extension('Event', 'EventCalendarExtension');
                } else {
                    Event::add_extension('EventCalendarExtension');
                }
                $s = self::subpackage_settings('calendars');
                if ($s['colors']) {
                    if ($ssversion == '3.0') {
                        Object::add_extension('Calendar', 'CalendarColorExtension');
                    } else {
                        Calendar::add_extension('CalendarColorExtension');
                    }
                }
                if ($s['shading']) {
                    if ($ssversion == '3.0') {
                        Object::add_extension('Calendar', 'ShadedCalendarExtension');
                    } else {
                        Calendar::add_extension('ShadedCalendarExtension');
                    }
                }
            }
            //Enabling categories
            if (self::subpackage_enabled('categories')) {
                if ($ssversion == '3.0') {
                    Object::add_extension('Event', 'EventCategoryExtension');
                } else {
                    Event::add_extension('EventCategoryExtension');
                }
            }
            //Enabling Event Page
            if (self::subpackage_setting('pagetypes', 'enable_eventpage')) {
                if ($ssversion == '3.0') {
                    Object::add_extension('Event', 'EventHasEventPageExtension');
                } else {
                    Event::add_extension('EventHasEventPageExtension');
                }
            }
            //Enabling debug mode
            if (self::subpackage_enabled('debug')) {
                if ($ssversion == '3.0') {
                    Object::add_extension('Event', 'EventDebugExtension');
                } else {
                    Event::add_extension('EventDebugExtension');
                }
            }
            //Enabling registrations
            if (self::subpackage_enabled('registrations')) {
                if ($ssversion == '3.0') {
                    Object::add_extension('Event', 'EventRegistrationExtension');
                } else {
                    Event::add_extension('EventRegistrationExtension');
                }
            }

            //Adding URL Segment extension to Calendar (currently done for all but could be made configurable later)
            Object::add_extension('Calendar', 'DoURLSegmentExtension');
            if ($ssversion == '3.0') {
                Object::add_extension('Calendar', 'DoURLSegmentExtension');
            } else {
                Calendar::add_extension('DoURLSegmentExtension');
            }
        }
    }
1107238
protected function addModelSettings(array &$settings)
    {
        $empty = $this->util->getTranslated()->getEmptyDropdownArray();

        $settings['elementClass'] = 'Select';
        $settings['multiOptions'] = $empty + $this->getLookup();
    }