Shortcut function for publishing JS files?

I publish JS files with the following code:




Yii::app()->clientScript->registerScriptFile(

    Yii::app()->assetManager->publish(

        Yii::getPathOfAlias('webroot').'/js/script.js'

    )

);



Is there shortcut function for doing this in Yii?

I think you should not publish to the assets folder, you just need some folder in the root for the js files.

So using


Yii::app()->clientScript->registerScriptFile('/js/script.js');

is enough.

But I am no expert. Hope helped.

Yes, here it is ;D


public function publishJs($file)

{

    Yii::app()->clientScript->registerScriptFile(

        Yii::app()->assetManager->publish( Yii::getPathOfAlias('webroot').$file);

    );

}