Exemplo n.º 1
0
 /**
  * @param int     $streamChannelId
  * @param CM_File $archiveSource
  */
 public function importVideoArchive($streamChannelId, CM_File $archiveSource)
 {
     $streamChannelArchive = new CM_Model_StreamChannelArchive_Video($streamChannelId);
     $archiveDestination = $streamChannelArchive->getVideo();
     $archiveDestination->ensureParentDirectory();
     $archiveSource->copyToFile($archiveDestination);
 }
Exemplo n.º 2
0
 /**
  * @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);
 }