Skip to content

Instantly share code, notes, and snippets.

@metalagman
Last active November 15, 2017 08:55
Show Gist options
  • Save metalagman/1363f845a4ffe8190833aa8ac727f904 to your computer and use it in GitHub Desktop.
Save metalagman/1363f845a4ffe8190833aa8ac727f904 to your computer and use it in GitHub Desktop.
Yii2 asset url resolving
/**
* @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