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;
}