コード例 #1
0
ファイル: MediaTest.php プロジェクト: cargomedia/cm
 public function testFindByMediaId()
 {
     $this->assertNull(CM_Model_StreamChannelArchive_Media::findByMediaId('foo'));
     /** @var CM_Model_StreamChannel_Media $streamChannel */
     $streamChannel = $streamChannel = CMTest_TH::createStreamChannel(null, null, 'foo');
     $this->assertEquals($streamChannel, CM_Model_StreamChannel_Media::findByMediaId($streamChannel->getMediaId()));
 }
コード例 #2
0
ファイル: Cli.php プロジェクト: cargomedia/cm
 /**
  * @param string  $streamChannelMediaId
  * @param CM_File $archiveSource
  * @throws CM_Exception_Invalid
  */
 public function importArchive($streamChannelMediaId, CM_File $archiveSource)
 {
     $streamChannelMediaId = (string) $streamChannelMediaId;
     $streamChannelArchive = CM_Model_StreamChannelArchive_Media::findByMediaId($streamChannelMediaId);
     if (!$streamChannelArchive) {
         $streamChannel = CM_Model_StreamChannel_Media::findByMediaId($streamChannelMediaId);
         if ($streamChannel) {
             throw new CM_Exception_Invalid('Archive not created, please try again later', null, ['streamChannelMediaId' => $streamChannelMediaId]);
         }
         $exception = new CM_Exception_Invalid('Archive not found, stream channel not found, skipping', CM_Exception::WARN, ['streamChannelMediaId' => $streamChannelMediaId]);
         $context = new CM_Log_Context();
         $context->setException($exception);
         $this->getServiceManager()->getLogger()->warning('Archive creating error', $context);
         return;
     }
     $filename = $streamChannelArchive->getId() . '-' . $streamChannelArchive->getHash() . '-original.' . $archiveSource->getExtension();
     $archiveDestination = new CM_File_UserContent('streamChannels', $filename, $streamChannelArchive->getId());
     $archiveDestination->ensureParentDirectory();
     $archiveSource->copyToFile($archiveDestination);
     $streamChannelArchive->setFile($archiveDestination);
 }