00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00023 class PEIP_Object_Event_Dispatcher
00024 extends PEIP_Object_Map_Dispatcher {
00025
00026
00027
00035 public function notify($name, $object, $eventClass = false){
00036 if($object instanceof PEIP_INF_Event){
00037 if(is_object($object->getContent())){
00038 if($this->hasListeners($name, $object->getContent())){
00039 return self::doNotify($this->getListeners($name, $object->getContent()), $object);
00040 }
00041 }else{
00042 throw new InvalidArgumentException('instance of PEIP_INF_Event must contain subject');
00043 }
00044 }else{
00045 throw new InvalidArgumentException('object must be instance of PEIP_INF_Event');
00046 }
00047 }
00048
00049
00058 public function buildAndNotify($name, $object, array $headers = array(), $eventClass = false){
00059 if($this->hasListeners($name, $object)){
00060 $event = PEIP_Event_Builder::getInstance($eventClass)->build($object, $name, $headers);
00061 return $this->notify($name, $event);
00062 }
00063 }
00064
00065
00066
00067
00068
00069
00070
00071
00072 }