Skip to content

Commit

Permalink
added anchor
Browse files Browse the repository at this point in the history
  • Loading branch information
jirisvoboda committed Jun 2, 2015
1 parent 0874f53 commit 61478ff
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion UrlManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public function init()
public function createUrl($params)
{
$params = (array) $params;
$anchor = isset($params['#']) ? $params['#'] : '';
$localeUrls = Yii::$app->localeUrls;

if (isset($params[$this->languageParam]))
Expand Down Expand Up @@ -106,6 +107,11 @@ public function createUrl($params)

$fullpath = sprintf('%s://%s/%s%s', $parts['scheme'], $parts['host'], $parts['path'], $this->suffix);

if ($anchor)
{
$fullpath = sprintf('%s#%s', $fullpath, $anchor);
}

if (isset($parts['query']))
{
return sprintf('%s?%s', $fullpath, $parts['query']);
Expand All @@ -114,7 +120,16 @@ public function createUrl($params)
return $fullpath;
}

return $length ? substr_replace($url, "$base/$language", 0, $length) : "/$language$url";
if ($length)
{
$path = substr_replace($url, "$base/$language", 0, $length);
}
else
{
$path = "/$language$url";
}

return $path.$anchor;
}
}
}

0 comments on commit 61478ff

Please sign in to comment.