Compiles the scope into regular expression patterns for matching against request URLs

@param array $config Array of settings.
@return array Returns the complied settings.
431466
protected static function _compileScope(array $config) {
		$defaults = [
			'absolute' => false,
			'host' => null,
			'scheme' => null,
			'base' => null,
			'prefix' => '',
			'pattern' => '',
			'params' => []
		];

		$config += $defaults;

		$config['prefix'] = trim($config['prefix'], '/');
		$prefix = '/' . ($config['prefix'] ? $config['prefix'] . '/' : '');

		if (!$config['absolute']) {
			$config['pattern'] = "@^{$prefix}@";
		} else {
			$fields = ['scheme', 'host'];
			foreach ($fields as $field) {
				$dots = '/(?!\{[^\}]*)\.(?![^\{]*\})/';
				$pattern[$field] = preg_replace($dots, '\.', $config[$field]);
				$match = '@\{:([^:}]+):?((?:[^{]+(?:\{[0-9,]+\})?)*?)\}@S';
				if (preg_match_all($match, $pattern[$field], $m)) {
					$tokens = $m[0];
					$names = $m[1];
					$regexs = $m[2];
					foreach ($names as $i => $name) {
						$regex = $regexs[$i] ? : '[^/]+?';
						$pattern[$field] = str_replace(
							$tokens[$i],
							"(?P<{$name}>{$regex})",
							$pattern[$field]
						);
						$config['params'][] = $name;
					}
				}
			}
			$pattern['host'] = $pattern['host'] ? : 'localhost';
			$pattern['scheme'] = $pattern['scheme'] . ($pattern['scheme'] ? '://' : '(.*?)//');
			$config['pattern'] = "@^{$pattern['scheme']}{$pattern['host']}{$prefix}@";
		}
		return $config;
	}
566915
public function execCurl(array $config)
    {
        $config[CURLOPT_VERBOSE]        = false;
        $config[CURLOPT_SSL_VERIFYPEER] = false;
        $config[CURLOPT_RETURNTRANSFER] = true;

        if (defined('CURLOPT_IPRESOLVE')) // PHP5.3
        {
            $config[CURLOPT_IPRESOLVE] = CURL_IPRESOLVE_V4;
        }

        $ch = curl_init();

        foreach ($config as $key => $value) {
            curl_setopt($ch, $key, $value);
        }

        $result      = curl_exec($ch);
        $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        $error       = curl_error($ch);
        $error_code  = curl_errno($ch);

        curl_close($ch);

        return [$result, $status_code, $error, $error_code];
    }
1259981
private function normalizeConfig(array $config)
    {
        // Backwards compatibility with old config format: `toolstack` is
        // changed to application `type` and `build`.`flavor`.
        if (isset($config['toolstack'])) {
            if (!strpos($config['toolstack'], ':')) {
                throw new InvalidConfigException("Invalid value for 'toolstack'");
            }
            list($config['type'], $config['build']['flavor']) = explode(':', $config['toolstack'], 2);
        }

        // The `web` section has changed to `web`.`locations`.
        if (isset($config['web']['document_root']) && empty($config['web']['locations'])) {
            $oldConfig = $config['web'] + $this->getOldWebDefaults();

            $location = &$config['web']['locations']['/'];

            $location['root'] = $oldConfig['document_root'];
            $location['expires'] = $oldConfig['expires'];
            $location['passthru'] = $oldConfig['passthru'];
            $location['allow'] = true;

            foreach ($oldConfig['whitelist'] as $pattern) {
                $location['allow'] = false;
                $location['rules'][$pattern]['allow'] = true;
            }

            foreach ($oldConfig['blacklist'] as $pattern) {
                $location['rules'][$pattern]['allow'] = false;
            }
        }

        return $config;
    }
1060790
protected function getDomain(array $config): string
    {
        $result = '';
        $parts = explode(',', $config['baseDn']);
        foreach ($parts as $part) {
            list($key, $value) = explode('=', $part);
            if ('dc' !== strtolower($key)) {
                continue;
            }

            $result .= '.' . $value;
        }

        $result = trim(trim($result, '.'));

        // fallback value
        if (empty($result)) {
            $result = $config['domain'] . '.com';
        }

        return $result;
    }
896808
public function generate(array $config)
    {
        $defaultHTTPCodes = $this->getDefaultHTTPCodes($config);
        $defaultOptions = $this->getDefaultOptions($config);

        return $this->createUrlChainFromConfig(
            $config,
            $defaultHTTPCodes,
            $defaultOptions
        );
    }
318368
protected function getOptionsFromConfig(Config $config)
    {
        $options = $this->options;

        if ($visibility = $config->get('visibility')) {
            // For local reference
            $options['visibility'] = $visibility;
            // For external reference
            $options['ACL'] = $visibility === AdapterInterface::VISIBILITY_PUBLIC ? 'public-read' : 'private';
        }

        if ($mimetype = $config->get('mimetype')) {
            // For local reference
            $options['mimetype'] = $mimetype;
            // For external reference
            $options['ContentType'] = $mimetype;
        }

        foreach (static::$metaOptions as $option) {
            if ( ! $config->has($option)) {
                continue;
            }
            $options[$option] = $config->get($option);
        }

        return $options;
    }
433871
protected function processConfig(array $config)
    {
        return [
            'model'      => $config['model'],
            'table'      => $this->getModelTable($config['model']),
            'field'      => snake_case($config['field']),
            'key'        => snake_case($this->key($config['key'])),
            'foreignKey' => snake_case($this->key($config['foreignKey'])),
        ];
    }
1328135
public static function config($config = null) {
		$defaults = ['scope' => null];

		if (is_array($config)) {
			foreach ($config as $i => $item) {
				$config[$i] += $defaults;
			}
		}
		return parent::config($config);
	}
1358321
protected function parseDescriptorField($config)
    {
        if (is_array($config)) {
            $descriptor = [];
            foreach ($config as $field) {
                if (!empty($this->{$field})) {
                    $descriptor[] = $this->{$field};
                }
            }

            return implode(' ', $descriptor);
        } else {
            return $this->{$config};
        }
    }
966032
protected function parseConfig(string $config): array
    {
        $config = json_decode($config, true);
        if ($config === null) {
            throw new ConfigFileFormatException("Config files should be written in valid JSON");
        }
        return $config;
    }
401729
protected function getRequestConfig(array $config) : array
    {
        if (!empty($this->defaultRequestOptions)) {
            $config = array_replace_recursive($this->defaultRequestOptions, $config);
        }

        return $config;
    }
262619
private function compile(array $config)
    {
        if (empty($config) or empty($config['pins']))
        {
            return '';
        }

        $maxAge = isset($config['max-age']) ? $config['max-age'] : 10;

        $pieces = ["max-age=$maxAge"];

        foreach ($config['pins'] as $pinAlg)
        {
            list($pin, $alg) = $pinAlg;

            $pieces[] = "pin-$alg=\"$pin\"";
        }

        if ($config['includesubdomains'])
        {
            $pieces[] = 'includeSubDomains';
        }

        if ($config['report-uri'])
        {
            $pieces[] = 'report-uri="' . $config['report-uri'] . '"';
        }

        return implode('; ', $pieces);
    }
299484
public function searchableContent(array $config = array())
    {
        $result = '';
        $type = $this->searchType();

        /*
         * Plain Bootstrap with glyphicons
         */
        if ('resource-table::bootstrap' === $this->_viewName) {
            switch ($type) {

                // Select
                case 'select':
                    if (!count($this->options())) {
                        // Options must be provided for select
                        return '';
                    }
                    $result .= '<select name="resource_table_'.$this->index().'" class="'.array_get($config, 'control_class', 'form-control input-sm').' resource-table-column-filter">'.$this->_optionsHTML().'</select>';
                    break;

                // Simple string input
                case 'string':
                default:
                    $result .= '<input type="text" placeholder="'.array_get($config, 'placeholder', trans('resource-table::default.Search_for').' '.$this->label()).'" class="'.array_get($config, 'control_class', 'form-control input-sm').' resource-table-column-filter" name="resource_table_'.$this->index().'" value="'.ResourceTable::getSearchValue($this->index()).'" />';
                    break;
            }
        }

        /*
         * Just simple table
         */
        if (!$result) {
            switch ($type) {

                // Select
                case 'select':
                    if (!count($this->options())) {
                        // Options must be provided for select
                        return '';
                    }
                    $result .= '<select name="resource_table_'.$this->index().'" class="'.array_get($config, 'control_class').' resource-table-column-filter">'.$this->_optionsHTML().'</select>';
                    break;

                // Simple string input
                case 'string':
                default:
                    $result .= '<input type="text" class="'.array_get($config, 'control_class').' resource-table-column-filter" name="resource_table_'.$this->index().'" value="'.ResourceTable::getSearchValue($this->index()).'" placeholder="'.array_get($config, 'placeholder').'" />';
                    break;
            }
        }

        return $result;
    }
334052
public function getParser(array $config = null)
	{
		$this->configOptimizer->reset();

		// Get the stylesheet used for rendering
		$xslt      = new XSLT;
		$xslt->optimizer->normalizer->remove('RemoveLivePreviewAttributes');
		$this->xsl = $xslt->getXSL($this->configurator->rendering);

		// Prepare the parser's config
		$this->config = (isset($config)) ? $config : $this->configurator->asConfig();
		$this->config = ConfigHelper::filterConfig($this->config, 'JS');
		$this->config = $this->callbackGenerator->replaceCallbacks($this->config);

		// Get the parser's source and inject its config
		$src = $this->getHints() . $this->injectConfig($this->getSource());

		// Export the public API
		$src .= "if (!window['s9e']) window['s9e'] = {};\n" . $this->getExports();

		// Minify the source
		$src = $this->getMinifier()->get($src);

		// Wrap the source in a function to protect the global scope
		$src = '(function(){' . $src . '})()';

		return $src;
	}
685869
public function parseFuelConfig(array $config)
	{
		$params = array();

		$params['driver'] = $config['type'];

		if ($params['driver'] === 'pdo')
		{
			list($type, $dsn) = explode(':', $config['connection']['dsn'], 2);

			$params['driver'] .= '_' . $type;

			$dsn = explode(';', $dsn);

			foreach ($dsn as $d)
			{
				list($k, $v) = explode('=', $d);

				$params[$k] = $v;
			}
		}
		else
		{
			$params['dbname'] = $config['connection']['database'];
			$params['host'] = $config['connection']['hostname'];
			$params['port'] = Arr::get($config, 'connection.port');
		}

		$params['user'] = Arr::get($config, 'connection.username');
		$params['password'] = Arr::get($config, 'connection.password');
		$params['charset'] = Arr::get($config, 'charset');

		return $params;
	}
872546
public static function config($config = []) {
		if (!$config) {
			return ['rules' => static::$_rules];
		}
		foreach ($config as $key => $val) {
			if (isset(static::${'_' . $key})) {
				static::${'_' . $key} = $val + static::${'_' . $key};
			}
		}
	}
499506
protected function getTargets(array $config)
    {
        if (!isset($config['targets'])
            || !is_array($config['targets'])
            || array_filter($config['targets'], 'is_array') != $config['targets']) {
            throw new \DomainException(
                'targets must be an array of arrays',
                self::ERR_TARGETS_INVALID
            );
        }
        return $config['targets'];
    }