I get an exception when trying to call isScriptFileRegistered()… I have a few widgets that use this js file, and a theme i created requires it as well. I am trying to make sure this js file isn't already loaded.
Maybe there is a better way to do this? Or maybe this is the correct way to go about it, I may be just doing it incorrectly?
class VsMootoolsWidget extends CWidget
/**
* init vs mootools widget
*/
public function init()
{
$clientScript = Yii::app()->getClientScript();
// Load Mootools js library
$mootoolsJs = dirname(__FILE__).DIRECTORY_SEPARATOR.'js'.DIRECTORY_SEPARATOR.'mootools-1.2.0-core.js';
if ( !$clientScript->isScriptFileRegistered($mootoolsJs) )
{
$mootoolsJsFile = Yii::app()->getAssetManager()->publish($mootoolsJs);
if (!$mootoolsJsFile == NULL)
{
$clientScript->registerScriptFile($mootoolsJsFile);
}
}
}
Property "CClientScript._bodyScriptFiles" is not defined.