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_Dispatcher 00024 extends PEIP_ABS_Dispatcher 00025 implements PEIP_INF_Dispatcher { 00026 00027 protected $listeners = array(); 00028 00041 public function connect(PEIP_INF_Handler $listener){ 00042 $this->listeners[] = $listener; 00043 } 00044 00059 public function disconnect(PEIP_INF_Handler $listener){ 00060 foreach ($this->listeners as $i => $callable){ 00061 if ($listener === $callable){ 00062 unset($this->listeners[$name][$i]); 00063 } 00064 } 00065 } 00066 00067 00080 public function hasListeners() 00081 { 00082 return (boolean) count($this->listeners); 00083 } 00084 00098 public function notify($subject){ 00099 if($this->hasListeners()){ 00100 return self::doNotify($this->getListeners(), $subject); 00101 } 00102 } 00103 00104 00124 public function notifyUntil($subject){ 00125 if($this->hasListeners()){ 00126 return self::doNotifyUntil($this->getListeners(), $subject); 00127 } 00128 } 00129 00142 public function getListeners(){ 00143 return $this->listeners; 00144 } 00145 00146 00147 00148 00149 00150 }