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 00022 class PEIP_Event_Pipe 00023 extends PEIP_ABS_Event_Pipe 00024 implements PEIP_INF_Listener { 00025 00026 protected 00027 $eventName; 00028 00029 00035 public function setInputChannel(PEIP_INF_Channel $inputChannel){ 00036 $this->connectChannel($inputChannel); 00037 } 00038 00039 00045 protected function doReply(PEIP_INF_Message $message){ 00046 $headerMessage = $message->getHeader('MESSAGE'); 00047 if($headerMessage instanceof PEIP_INF_Message){ 00048 return $this->replyMessage($headerMessage); 00049 } 00050 } 00051 00052 00058 public function listen(PEIP_INF_Connectable $connectable){ 00059 return $this->doListen($this->eventName, $connectable); 00060 } 00061 00062 00068 public function unlisten(PEIP_INF_Connectable $connectable){ 00069 return $this->doUnlisten($this->eventName, $connectable); 00070 } 00071 00072 00077 public function getConnected(){ 00078 return $this->doGetConnected(); 00079 } 00080 00081 00082 00088 public function disconnectChannel(PEIP_INF_Channel $channel){ 00089 $this->disconnectInputChannel(); 00090 $this->inputChannel = $channel; 00091 $this->connectInputChannel(); 00092 } 00093 00098 protected function connectInputChannel(){ 00099 if($this->inputChannel && $this->eventName){ 00100 $this->inputChannel->connect($this->eventName, $this); 00101 } 00102 } 00103 00104 00109 protected function disconnectInputChannel(){ 00110 if($this->inputChannel && $this->eventName){ 00111 $this->inputChannel->disconnect($this->eventName, $this); 00112 } 00113 } 00114 00115 00121 public function setEventName($eventName){ 00122 $this->disconnectInputChannel(); 00123 $this->eventName = $eventName; 00124 $this->connectInputChannel(); 00125 } 00126 00127 }