thrownewDoctrine_EventListener_Exception("Couldn't add eventlistener. EventListeners should implement either Doctrine_EventListener_Interface or Doctrine_Overloadable");
}
if($name===null){
$this->_listeners[]=$listener;
}else{
$this->_listeners[$name]=$listener;
}
}
/**
* returns a Doctrine_EventListener on success
* and null on failure
*
* @param mixed $key
* @return mixed
*/
publicfunctionget($key)
{
if(!isset($this->_listeners[$key])){
returnnull;
}
return$this->_listeners[$key];
}
/**
* set
*
* @param mixed $key
* @param Doctrine_EventListener $listener
* @return void
*/
publicfunctionset($key,$listener)
{
if(!$listenerinstanceOfDoctrine_EventListener){
thrownewDoctrine_Exception('Value variable in set is not an instance of Doctrine_EventListener');
}
$this->_listeners[$key]=$listener;
}
/**
* onLoad
* an event invoked when Doctrine_Entity is being loaded from database
*
* @param Doctrine_Entity $record
* @return void
*/
publicfunctiononLoad(Doctrine_Entity$record)
{
foreach($this->_listenersas$listener){
$listener->onLoad($record);
}
}
/**
* onPreLoad
* an event invoked when Doctrine_Entity is being loaded
* from database but not yet initialized
*
* @param Doctrine_Entity $record
* @return void
*/
publicfunctiononPreLoad(Doctrine_Entity$record)
{
foreach($this->_listenersas$listener){
$listener->onPreLoad($record);
}
}
/**
* onSleep
* an event invoked when Doctrine_Entity is serialized
*
* @param Doctrine_Entity $record
* @return void
*/
publicfunctiononSleep(Doctrine_Entity$record)
{
foreach($this->_listenersas$listener){
$listener->onSleep($record);
}
}
/**
* onWakeUp
* an event invoked when Doctrine_Entity is unserialized
*
* @param Doctrine_Entity $record
* @return void
*/
publicfunctiononWakeUp(Doctrine_Entity$record)
{
foreach($this->_listenersas$listener){
$listener->onWakeUp($record);
}
}
/**
* postClose
* an event invoked after Doctrine_Connection is closed
*
* @param Doctrine_Event $event
* @return void
*/
publicfunctionpostClose(Doctrine_Event$event)
{
foreach($this->_listenersas$listener){
$listener->postClose($event);
}
}
/**
* preClose
* an event invoked before Doctrine_Connection is closed
*
* @param Doctrine_Event $event
* @return void
*/
publicfunctionpreClose(Doctrine_Event$event)
{
foreach($this->_listenersas$listener){
$listener->preClose($event);
}
}
/**
* onOpen
* an event invoked after Doctrine_Connection is opened
thrownewDoctrine_EventListener_Exception("Couldn't add eventlistener. Record listeners should implement either Doctrine_EventListener_Interface or Doctrine_Overloadable");
}
if($name===null){
$this->_listeners[]=$listener;
}else{
$this->_listeners[$name]=$listener;
}
}
/**
* returns a Doctrine_Record_Listener on success
* and null on failure
*
* @param mixed $key
* @return mixed
*/
publicfunctionget($key)
{
if(!isset($this->_listeners[$key])){
returnnull;
}
return$this->_listeners[$key];
}
/**
* set
*
* @param mixed $key
* @param Doctrine_Record_Listener $listener listener to be added
* @return Doctrine_Record_Listener_Chain this object
thrownewDoctrine_EventListener_Exception("Couldn't add eventlistener. Record listeners should implement either Doctrine_EventListener_Interface or Doctrine_Overloadable");