PEIP_Object_Event_Dispatcher.php

Go to the documentation of this file.
00001 <?php
00002 
00003 /*
00004  * This file is part of the PEIP package.
00005  * (c) 2010 Timo Michna <timomichna/yahoo.de>
00006  * 
00007  * For the full copyright and license information, please view the LICENSE
00008  * file that was distributed with this source code.
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 }

Generated on Mon Apr 12 11:39:00 2010 for PEIP by  doxygen 1.5.1