Set/get settings.

@param array $settings
@return array
773309
public function settings(array $settings = null)
    {
        if ($settings !== null) {
            $this->settings = $settings;
        }

        return $this->settings;
    }
735321
protected static function validateSettings($settings)
    {
        if (!isset($settings['consumerKey']) || !isset($settings['consumerSecret'])) {
            return false;
        }
        $settings['token'] = isset($settings['token']) ? $settings['token'] : null;
        $settings['tokenSecret'] = isset($settings['tokenSecret']) ? $settings['tokenSecret'] : null;

        return $settings;
    }
1155054
public function getPdo($settings)
    {
        if (isset($settings['pdo']) && $settings['pdo'] instanceof PDO) {
            $settings['pdo']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            $settings['pdo']->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);

            return $settings['pdo'];
        }
        $options = array_replace_recursive($settings['options'], [
            // Enable exceptions
            PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
            // Set default fetch mode
            PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
        ]);
        $pdo = new PDO($settings['dsn'], $settings['username'], $settings['password'], $options);

        return $pdo;
    }
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++;
        }
    }
355796
public function setSettings(array $settings = []) : self
    {
        $this->settings = array_merge($this->settings, $settings);
        // loop through checking each setting
        foreach ($this->allowedSettings as $name => $allowed) {
            $this->validateSettings->__invoke($name, $this->settings[$name], $allowed);
        }

        return $this;
    }
1203454
public function getSetting(string $setting) {
		$settings = $this->getSettings();
		$keys = array_keys($settings);
		
		if (!in_array($setting, $keys)) {
			throw new ControllerException("Unknown setting: $setting.",
				ControllerException::UNKNOWN_SETTING);
		}
		
		return $settings[$setting];
	}
410997
protected function createMailer( $settings = null ) {
		$settings = is_array( $settings ) ? $settings : [];
		$mailer = new PHPMailer( true );
		foreach ( array_merge( $this->settings, $settings ) as $key => $value ) {
			$mailer->set( $key, $value );
		}
		return $mailer;
	}
408015
function setSetting($setting)
    {
        if (!is_string($setting) && !is_array($setting) && !$setting instanceof \Traversable)
            throw new \InvalidArgumentException(sprintf(
                'Config must be array, Traversable or string as service represent these both; given: (%s).'
                , \Poirot\Std\flatten($setting)
            ));

        $this->setting = $setting;
        return $this;
    }
674275
public function saveSettings($settings)
    {
        if (isset($settings['name']) && isset($this->config['servers'][$settings['name']])) {
            return $this->saveConfig(array_merge($this->config['servers'][$settings['name']], $settings));
        }
    }
503039
public function presetProperties(array &$properties)
    {
        $definitions = Config::getCommonDefinitions();
		
        foreach ($definitions as $definition) {
            $patterns = $this->getArrayByKey($definition, 'match');

            if (Helpers::strIs($patterns, $properties['name'])) {
                //auto add any config from the master config
                $settings = $this->getArrayByKey($definition, 'set');
				
                foreach ($settings as $key => $setting) {
					
                    if (!Helpers::isKeyExists($properties, $key) || empty($properties[$key])) {
                        $properties[$key] = $setting;
                    }
                }
            }
        }

        return $this;
    }
671911
final public static function get_instance( array $setting = [] ) {
		$class_name = get_called_class();
		if ( ! isset( self::$instances[ $class_name ] ) ) {
			self::$instances[ $class_name ] = new $class_name( $setting );
		}

		return self::$instances[ $class_name ];
	}
1011918
public function resolve(array $settings = [])
    {
        return [
            'driver'              => 'pdo_sqlite',
            'user'                => Arr::get($settings, 'username'),
            'password'            => Arr::get($settings, 'password'),
            'prefix'              => Arr::get($settings, 'prefix'),
            'memory'              => $this->isMemory($settings),
            'path'                => Arr::get($settings, 'database'),
            'defaultTableOptions' => Arr::get($settings, 'defaultTableOptions', []),
        ];
    }
386308
protected function _prepareTransport(array $settings) {
        $config = array();

        if (!empty($settings['transportDir'])) {
            $config['folder'] = $settings['transportDir'];
        }

        if (!empty($settings['returnUrl'])) {
            $config['returnUrl'] = $settings['returnUrl'];
        }

        return $config;
    }
757959
public function setSettings($settings = [])
    {
        $original = $this->settings;
        $this->mergeSettings($settings, $this->settings);
        if ($this->settings != $original) {
            // @todo - Log Curl equivalent during test mode (adds overhead and risk so only do it during test)
            // if (!isset($this->settings['handler']) && class_exists(
            //         '\Namshi\Cuzzle\Middleware\CurlFormatterMiddleware'
            //     )) {
            //     $this->logger      = new Logger('guzzle.to.curl'); //initialize the logger
            //     $this->testHandler = new TestHandler(); //test logger handler
            //     $this->logger->pushHandler($this->testHandler);
            //
            //     $this->handler = HandlerStack::create();
            //     $this->handler->after('cookies', new \Namshi\Cuzzle\Middleware\CurlFormatterMiddleware($this->logger));
            //     $this->settings['handler'] = $this->handler;
            // }
            $this->client = new Client($this->settings);
        }
    }
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'];
		}
	}
1357947
public static function hydrateCollection(array $settings)
    {
        $hydrated = [];

        foreach ($settings as $setting) {
            $hydrated[] = self::hydrate($setting);
        }

        return $hydrated;
    }
1309967
protected function addModelSettings(array &$settings)
    {
        $empty = [];
        if (!$this->_fieldDefinition['gtf_required'] || $this->_fieldDefinition['gtf_field_default'] === null) {
            $empty = $this->util->getTranslated()->getEmptyDropdownArray();
        }

        $multi = explode(parent::FIELD_SEP, $this->_fieldDefinition['gtf_field_values']);

        $settings['elementClass'] = 'Select';
        $settings['multiOptions'] = $empty + array_combine($multi, $multi);
    }