00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00022 abstract class PEIP_ABS_Map_Dispatcher
00023 extends
00024 PEIP_ABS_Dispatcher
00025 implements
00026
00027 PEIP_INF_Connectable {
00028
00029 protected
00030 $listeners = array();
00031
00032
00046 public function connect($name, PEIP_INF_Handler $listener)
00047 {
00048 if (!isset($this->listeners[$name]))
00049 {
00050 $this->listeners[$name] = array();
00051 }
00052
00053 $this->listeners[$name][] = $listener;
00054 }
00055
00071 public function disconnect($name, PEIP_INF_Handler $listener)
00072 {
00073 if (!isset($this->listeners[$name]))
00074 {
00075 return false;
00076 }
00077
00078 foreach ($this->listeners[$name] as $i => $callable)
00079 {
00080 if ($listener === $callable)
00081 {
00082 unset($this->listeners[$name][$i]);
00083 }
00084 }
00085 }
00086
00087
00101 public function hasListeners($name)
00102 {
00103 if (!isset($this->listeners[$name]))
00104 {
00105 $this->listeners[$name] = array();
00106 }
00107 return (boolean) count($this->listeners[$name]);
00108 }
00109
00124 public function notify($name, $subject){
00125 if($this->hasListeners($name)){
00126 return self::doNotify($this->getListeners($name), $subject);
00127 }
00128 }
00129
00130
00152 public function notifyUntil($name, $subject){
00153 if($this->hasListeners($name)){
00154 return self::doNotifyUntil($this->getListeners($name), $subject);
00155 }
00156 }
00157
00171 public function getListeners($name)
00172 {
00173 if (!isset($this->listeners[$name])){
00174 return array();
00175 }
00176 return $this->listeners[$name];
00177 }
00178
00179
00180 }
00181