lithium\net\http\Router::_matchOptions PHP Method

_matchOptions() protected static method

Initialize options for Router::match().
protected static _matchOptions ( string | array &$url, Request $context, array $options ) : array
$url string | array Options to match to a URL. Optionally, this can be a string containing a manually generated URL.
$context lithium\action\Request
$options array Options for the generation of the matched URL.
return array The initialized options.
    protected static function _matchOptions(&$url, $context, $options)
    {
        $defaults = array('scheme' => null, 'host' => null, 'absolute' => false, 'base' => '');
        if ($context) {
            $defaults = array('base' => $context->env('base'), 'host' => $context->host, 'scheme' => $context->scheme . ($context->scheme ? '://' : '//')) + $defaults;
        }
        $options += array('scope' => static::scope());
        $vars = array();
        $scope = $options['scope'];
        if (is_array($scope)) {
            list($tmp, $vars) = each($scope);
            if (!is_array($vars)) {
                $vars = $scope;
                $scope = static::scope();
            } else {
                $scope = $tmp;
            }
        }
        if ($config = static::attached($scope, $vars)) {
            if (is_array($url)) {
                unset($url['library']);
            }
            $config['host'] = $config['host'] ?: $defaults['host'];
            if ($config['scheme'] === false) {
                $config['scheme'] = '//';
            } else {
                $config['scheme'] .= $config['scheme'] ? '://' : $defaults['scheme'];
            }
            $config['scheme'] = $config['scheme'] ?: 'http://';
            $base = isset($config['base']) ? '/' . $config['base'] : $defaults['base'];
            $base = $base . ($config['prefix'] ? '/' . $config['prefix'] : '');
            $config['base'] = rtrim($config['absolute'] ? '/' . trim($base, '/') : $base, '/');
            $defaults = $config + $defaults;
        }
        return $options + $defaults;
    }