/** * @param string $mediaId * @return CM_Model_StreamChannel_Media|null */ public static function findByMediaId($mediaId) { $row = CM_Db_Db::exec("SELECT t1.id, t2.type FROM cm_streamChannel_media t1 JOIN cm_streamChannel t2 USING(id) WHERE t1.mediaId = ?", [(string) $mediaId])->fetch(); if (!$row) { return null; } $streamChannelId = $row['id']; $streamChannelType = $row['type']; return CM_Model_StreamChannel_Media::factory($streamChannelId, $streamChannelType); }
/** * @expectedException CM_Exception_Invalid * @expectedExceptionMessage Unexpected instance */ public function testFactoryInvalidInstance() { $messageStreamChannel = CM_Model_StreamChannel_Message::createStatic(array('key' => 'message-stream-channel', 'adapterType' => CM_MessageStream_Adapter_SocketRedis::getTypeStatic())); CM_Model_StreamChannel_Media::factory($messageStreamChannel->getId()); }