[SOLVED] How to create a child class

Hi all,

I have a very basic question.

I need to override a standard class’ behaviour, eg. using my own descendant of CWebUser. What is the right approach of doing that?

Can I create a derived class CMyWebUser in the components/ dir, and then update the config as follows:




return array(

  ...

  'components'=>array(

    'user'=>array(

      'class'=>'CMyWebUser',

    ),

  ),

  ...

)



Yes, you can.




'import' => array(

        'path.to.CMyWebUser',

),

'components'=>array(

    'user'=>array(

      'class'=>'path.to.CMyWebUser',

    ),

  ),



Cheers,

Matt

Cheers Matt,

In fact, in the default configuration all the components are imported:


	'import'=>array(

		'application.models.*',

		'application.components.*',

	),



And it’s not necessary to include path in the components array, component class name is sufficient.