How to extract cssFiles and scriptFiles from Yii::app()->getClientScript();

As part of an AJAX request I’m trying to get at the contents of cssFiles and scriptFiles after calling Yii::app()->getClientScript();

I’ve tried extending CClientScript with getters, but how do I make Yii::app()->getClientScript() extend from my version?

My extended class is in components/MyCClientScript

I’ve tried adding several variants along the lines of this to the config, but all to no avail.




	'components'=>array(

		'CClientScript' =>array(

			'class'=>'ext.MyCClientScript.MyCClientScriptClass',

		),



Finally worked it out.

In the config, when overriding a class, you have to refer to it by its name minus the C and lowercase the first letter. No idea why this is the case.

eg




'components'=>array(

	'clientScript' =>array(

		'class'=>'MyClientScript',

	),

...

),



I think that in the ‘components’ part of the config file, all ApplicationComponents are listed. And the name are referring not to the class but to the name of the application attribute containing the component.

So you will say :

‘clientScript’ => for replacing or configure Yii::app()->clientScript (base class : CClientScript)

‘user’ => for replacing or configure Yii::app()->user (base class: CWebUser)