yiisoft / yii

Yii PHP Framework 1.1.x
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
4.85k stars 2.28k forks source link

Yii::getPathOfAlias should work with directories that have a 'dot' #4058

Closed pohnean closed 8 years ago

pohnean commented 8 years ago

Currently the Yii::getPathOfAlias function will simply translate any dots to DIRECTORY_SEPARATOR.

As a result, the path for folders with dot as a name is not translated correctly. Example: Yii::getPathOfAlias('node_modules.typeahead.js') becomes:

/node_modules/typeahead/js Proposed solution: Allow dots in aliases by escaping them: Yii::getPathOfAlias('node_modules.typeahead\.js')
cebe commented 8 years ago

the problem is fixed in yii2, so we are not going to so anything about it in yii1 as it would break BC. Sorry.

georgezim85 commented 5 years ago

Imagine that you need to publish an asset from a directory called "jquery.complexify" in "your_app/node_modules/" There goes an example:

$baseUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('webroot.node_modules') . DIRECTORY_SEPARATOR . 'jquery.complexify');
$cs = Yii::app()->getClientScript();
$cs->registerScriptFile($baseUrl . DIRECTORY_SEPARATOR . 'jquery.complexify.js');