How to attach behavior with main/config

Hi,

I wrote the behavior:




class LogLoginBehavior extends CBehavior {

  public function getEnabled() {     throw new Exception ( 'DDD'  ); return true; }

  public function login ( $identity, $duration = 0 ){

    throw new Exception ( 'DDD'  );

    User::model()->findByPk( $identity->id )->hasLogined();

    $this->owner->login( $identity, $duration );    

  }

}

and changed the user component configure:




'user'=>array(

               'allowAutoLogin'=>true,

               'behaviors' => array (

                      'loglogin' => array ( 'class' => 'application.components.LogLoginBehavior', 

                                            'enabled' => true  ) )

               )

But the exception doesn’t appeared.

Where did I a mistaken?

I fixed the problem with other way.

I inherited WebUser class and overrode its login method.


'user'=>array( 'allowAutoLogin'=>true,               

                'class' => 'application.components.WebUser',

             )


class WebUser extends CWebUser {

  private $_user_model = null;

  public function getUserModel(){ return $this->_user_model ; } 

  public function getIsRoot () {

    return $this->_user_model && $this->_user_model->login === 'dan' ;

  }

  public function getCanArticle () {

    return $this->_user_model && $this->_user_model->can_write_articles ;    

  }

  public function getCanComment () {

    return $this->_user_model && $this->_user_model->can_write_comments ;    

  }

  public function login( $identity, $duration = 0 ){

    parent::login( $identity, $duration );

    User::model()->findByPk( $identity->id )->hasLogined();    

  }

}