/** * gets channel by channel id * @param $channelId * @return Pap_Db_Channel * @throws Gpf_Exception */ public function getChannelById(Pap_Contexts_Tracking $context, $channelId) { if($channelId == '') { $this->logAndThrow($context, 'Channel id is empty'); } $user = $context->getUserObject(); if ($user == null) { $this->logAndThrow($context, 'User is not recognized. Channel can not be found'); } if (isset($this->channelsCache[$channelId])) { return $this->channelsCache[$channelId]; } $channel = new Pap_Db_Channel(); $channel->setPrimaryKeyValue($channelId); $channel->setPapUserId($user->getId()); try { $channel->loadFromData(array(Pap_Db_Table_Channels::ID, Pap_Db_Table_Channels::USER_ID)); $context->debug('Channel found: '.$channel->getName()); $this->channelsCache[$channelId] = $channel; return $channel; } catch (Gpf_DbEngine_NoRowException $e) { $channel->setValue($channelId); $channel->loadFromData(array(Pap_Db_Table_Channels::VALUE, Pap_Db_Table_Channels::USER_ID)); $this->channelsCache[$channelId] = $channel; return $channel; } }