28 $def = $config->getDefinition(
'URI');
29 $this->base = $def->base;
30 if (is_null($this->base)) {
32 'URI.MakeAbsolute is being ignored due to lack of ' .
33 'value for URI.Base configuration',
38 $this->base->fragment = null;
39 $stack = explode(
'/', $this->base->path);
42 $this->basePathStack = $stack;
52 public function filter(&$uri, $config, $context)
54 if (is_null($this->base)) {
57 if ($uri->path ===
'' && is_null($uri->scheme) &&
58 is_null($uri->host) && is_null($uri->query) && is_null($uri->fragment)) {
63 if (!is_null($uri->scheme)) {
65 if (!is_null($uri->host)) {
68 $scheme_obj = $uri->getSchemeObj($config, $context);
73 if (!$scheme_obj->hierarchical) {
79 if (!is_null($uri->host)) {
83 if ($uri->path ===
'') {
84 $uri->path = $this->base->path;
85 } elseif ($uri->path[0] !==
'/') {
87 $stack = explode(
'/', $uri->path);
88 $new_stack = array_merge($this->basePathStack, $stack);
89 if ($new_stack[0] !==
'' && !is_null($this->base->host)) {
90 array_unshift($new_stack,
'');
93 $uri->path = implode(
'/', $new_stack);
96 $uri->path = implode(
'/', $this->
_collapseStack(explode(
'/', $uri->path)));
99 $uri->scheme = $this->base->scheme;
100 if (is_null($uri->userinfo)) {
101 $uri->userinfo = $this->base->userinfo;
103 if (is_null($uri->host)) {
104 $uri->host = $this->base->host;
106 if (is_null($uri->port)) {
107 $uri->port = $this->base->port;
121 for ($i = 0; isset($stack[$i]); $i++) {
124 if ($stack[$i] ==
'' && $i && isset($stack[$i + 1])) {
127 if ($stack[$i] ==
'..') {
130 if ($segment ===
'' && empty(
$result)) {
134 } elseif ($segment ===
'..') {
144 if ($stack[$i] ==
'.') {