<?php
class Kaf_User_Identity extends CUserIdentity{
public $id, $email;
public function authenticate(){
/*
beforeAuthenticate();
raise event here,
could one of the event handlers signals to stop the execution
of this method and return a value provided by this handler?
In this case, codes bellow will not be executed.
*/
list($code, $this->username, $this->password, $this->email) = $ucc->user_login($this->username, $this->password);
if($ucc->hasError()){
$this->errorCode = $code;
}
else{
$this->id = $code;
$this->errorCode = self::ERROR_NONE;
$this->setState('email', $this->email);
}
return $this->getIsAuthenticated();
}
public function getId(){
return $this->id;
}
protected function beforeAuthenticate(){
if($this->hasEventHandler('onBeforeAuthenticate')){
$event = new CEvent($this);
$this->onBeforeSave($event);
return $event->handled;
}
else{
return true;
}
}
public function onBeforeAuthenticate($event){
$this->raiseEvent('onBeforeAuthenticate', $event);
}
}
I don’t really understand your code example. But the way events work, you can’t have a return value. A way to do something similar in an OOP manner would be, to use a property in a CEvent object (or some extended class) that you pass along when you trigger the event. Every handler will receive this event object and can alter its properties. After all handlers did their job, you can inspect this property.