signalsBlocked === false && isset( $this->connections[$signal] ) ) { // fetch parameters, remove the signal part $args = func_get_args(); unset( $args[0] ); foreach( $this->connections[$signal] as $c ) { call_user_func_array( array( $c->receiver, $c->slot ), $args ); } } } /** * Connects a signal to a slot. * * TODO: add some sort of type safety to this system * also add check that the slot really exists. * if we want to check if the signal exists we need some system to * retrieve all the signals. Do we want that? */ public function connect( $signal, Object $receiver, $slot ) { if( !isset( $this->connections[$signal] ) ) { $this->connections[$signal] = array(); } $c = new Connection(); $c->slot = $slot; $c->receiver = $receiver; $this->connections[$signal][] = $c; } public function disconnect( $signal, Object $receiver, $slot ) { if( !isset( $this->connections[$signal] ) ) { // TODO: warning, no such found return; } foreach( $this->connections[$signal] as $counter => $connection ) { if( $slot == $connection->slot ) { unset( $this->connections[$signal][$counter] ); return; } } // TODO: warning, no such found } public function blockSignals( $blockSignals ) { $this->signalsBlocked = $blockSignals; } public function signalsBlocked() { return $this->signalsBlocked; } } ?>