Set miscellaneous configuration (support method for constructor).

@param array $settings Configuration

@return void
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'];
        }
    }
26126
public static function configure($settings)
    {
        if (isset($settings['client_id'])) {
            self::configureOAuth($settings);
        } else {
            self::configureBasicAuth($settings);
        }
    }
947619
public static function configureBasicAuth(array $settings)
    {
        if (!isset($settings['store_url'])) {
            throw new Exception("'store_url' must be provided");
        }

        if (!isset($settings['username'])) {
            throw new Exception("'username' must be provided");
        }

        if (!isset($settings['api_key'])) {
            throw new Exception("'api_key' must be provided");
        }

        self::$username = $settings['username'];
        self::$api_key = $settings['api_key'];
        self::$store_url = rtrim($settings['store_url'], '/');
        self::$api_path = self::$store_url . self::$path_prefix;
        self::$connection = false;
    }
351126
public function restore(array $settings = array())
    {
        $settings = array_values($settings);

        $reflection = new ReflectionMethod(get_class($this), '__construct');
        $alreadySet = $reflection->getNumberOfParameters();

        $index = 0;

        foreach($this->settings as &$setting)
        {
            if($alreadySet > $index)
            {
                continue;
            }

            if(array_key_exists($index, $settings))
            {
                $setting = $settings[$index] === '' ? NULL : $settings[$index];
            }

            $index++;
        }
    }
810152
public function set($settings) {

        if (!$this->simple) {
            if (is_a($this->source, 'ToolConsumer')) {
                $type = 'ToolProxy';
            } else if (is_a($this->source, 'ToolConsumer')) {
                $type = 'ToolProxyBinding';
            } else {
                $type = 'LtiLink';
            }
            $obj = new \stdClass();
            $obj->{'@context'} = 'http://purl.imsglobal.org/ctx/lti/v2/ToolSettings';
            $obj->{'@graph'} = array();
            $level = new \stdClass();
            $level->{'@type'} = $type;
            $level->{'@id'} = $this->endpoint;
            $level->{'custom'} = $settings;
            $obj->{'@graph'}[] = $level;
            $body = json_encode($obj);
        } else {
            $body = json_encode($settings);
        }

        $response = parent::send('PUT', null, $body);

        return $response->ok;

    }
1007903
private function setSettings($settings)
    {
        if ($settings) {
            foreach ($this->settings as $key => &$value) {
                if (!empty($settings->{$key}) && $settings->{$key}) {
                    if (is_object($settings->{$key})) {
                        $value = array_merge(
                            $value,
                            json_decode(json_encode($settings->{$key}, JSON_FORCE_OBJECT), true)
                        );
                    } else {
                        $value = $settings->{$key};
                    }
                }
            }
        }
    }
807997
protected function configureSettings(InputInterface $input, OutputInterface $output, array $settings)
    {
        $configuration = Configuration::getInstance();

        foreach ($settings as $name => $value) {
            $configuration->setValue($name, $value);
        }
    }
936045
public function injectSettings(array $settings = null) {
		$this->settings = ($settings === null) ? array() : $settings;

		// register default snippets
		$this->add(new DefaultSnippets());

		if (array_key_exists('snippets', $this->settings)) {
			foreach ($this->settings['snippets'] as $snippet=>$definition) {
				if ($definition instanceof Snippets) {
					$this->add($definition);
				} else {
					$this->add($snippet, $definition);
				}
			}
		}
	}
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'];
		}
	}
130589
public function setLinkDefaults(array $Settings = [])
    {
        if (isset($Settings["R"])) {
            $this->Default["LinkR"] = $Settings["R"];
        }
        if (isset($Settings["G"])) {
            $this->Default["LinkG"] = $Settings["G"];
        }
        if (isset($Settings["B"])) {
            $this->Default["LinkB"] = $Settings["B"];
        }
        if (isset($Settings["Alpha"])) {
            $this->Default["LinkAlpha"] = $Settings["Alpha"];
        }
    }
1038059
public function setLabelsSettings(array $Settings = [])
    {
        if (isset($Settings["Type"])) {
            $this->Labels["Type"] = $Settings["Type"];
        }
        if (isset($Settings["R"])) {
            $this->Labels["R"] = $Settings["R"];
        }
        if (isset($Settings["G"])) {
            $this->Labels["G"] = $Settings["G"];
        }
        if (isset($Settings["B"])) {
            $this->Labels["B"] = $Settings["B"];
        }
        if (isset($Settings["Alpha"])) {
            $this->Labels["Alpha"] = $Settings["Alpha"];
        }
    }
162370
public static function overload(array $settings)
    {
        if (self::mustLoad()) {
            self::load();
        }
        foreach ($settings as $var=>$val) {
            self::set($var, $val);
        }
    }
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);
            }
        }
    }
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'];
        }
    }
149356
public function setOptions( array $options )
    {
        foreach ( $this->defaults as $option => $defaults ) {
            $this->values[$option] = ( array_key_exists($defaults['name'], $options) ) ? $options[$option] : $defaults['default'];
        }
    }
1046306
protected function updateSettings(array $settings)
    {
        $this->controlAccess('module_edit');

        $this->module->setSettings('export', $settings);
        $this->redirect('', $this->text('Settings have been updated'), 'success');
    }
435455
public static function setMany($settings = [], $defaultSettings = [])
    {
        $settings = static::parseDefaultOptions($settings, $defaultSettings);

        array_walk($settings, function ($value, $key) {
            static::set($key, $value);
        });
    }