Last active
November 15, 2017 08:55
-
-
Save metalagman/1363f845a4ffe8190833aa8ac727f904 to your computer and use it in GitHub Desktop.
Yii2 asset url resolving
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param $url | |
* @return string | |
* @throws \yii\base\InvalidConfigException | |
*/ | |
public static function getAssetUrl($url) | |
{ | |
$class = ArrayHelper::getValue([ | |
'app-frontend' => \frontend\assets\AppAsset::class, | |
], \Yii::$app->id); | |
return \Yii::$app->assetManager->getBundle($class)->baseUrl . $url; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment