Answer the question
In order to leave comments, you need to log in
How to add a prefix to an asset link?
Greetings.
Any ideas how to do the following - add a prefix to the url of assets after registering them? For example, I register SomeAssetBundle in which statics from $sourcePath are published. I get the path /assets/%hash%/%filename% after publishing. The task is to add a prefix in the received path, for example /test/assets/%hash%/%filename%
Answer the question
In order to leave comments, you need to log in
Extended the SomeAssetBundle class with the method
/**
* Добавляет префикс к урлу
*
* @param string $prefix Префикс ссылки
*/
public function updateBaseUrl($prefix)
{
$this->baseUrl = DIRECTORY_SEPARATOR . $prefix . $this->baseUrl;
}
$bundle = test\components\SomeAssetBundle ::register($this);
$bundle->updateBaseUrl('test');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question