From e758608a5a563ffff07c5b6b98a31dd41d7e7e3c Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Sun, 9 Mar 2014 18:02:24 +0400 Subject: [PATCH] Added Url::asset --- framework/helpers/BaseUrl.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/framework/helpers/BaseUrl.php b/framework/helpers/BaseUrl.php index 3444a22..a6cb619 100644 --- a/framework/helpers/BaseUrl.php +++ b/framework/helpers/BaseUrl.php @@ -57,9 +57,20 @@ class BaseUrl if ($url !== '' && ($url[0] === '/' || $url[0] === '#' || strpos($url, '://') || !strncmp($url, './', 2))) { return $url; } else { - return Yii::$app->getRequest()->getBaseUrl() . '/' . $url; + return static::asset($url); } } } + + /** + * Prefixes relative URL with base URL + * + * @param string $url relative URL + * @return string absolute URL + */ + public function asset($url) + { + return Yii::$app->getRequest()->getBaseUrl() . '/' . $url; + } } \ No newline at end of file