예제 #1
0
 public function testGetUrl()
 {
     $serviceManager = new CM_Service_Manager();
     $filesystemDefault = new CM_File_Filesystem(new CM_File_Filesystem_Adapter_Local());
     $filesystemFoo = new CM_File_Filesystem(new CM_File_Filesystem_Adapter_Local());
     $serviceManager->registerInstance('filesystem-usercontent-default', $filesystemDefault);
     $serviceManager->registerInstance('filesystem-usercontent-foo', $filesystemFoo);
     $serviceConfig = array('default' => array('url' => 'http://example.com/default', 'filesystem' => 'filesystem-usercontent-default'), 'foo' => array('url' => 'http://example.com/foo', 'filesystem' => 'filesystem-usercontent-foo'));
     $serviceManager->registerInstance('usercontent', new CM_Service_UserContent($serviceConfig));
     $userFile = new CM_File_UserContent('foo', 'my.jpg', null, $serviceManager);
     $this->assertSame('http://example.com/foo/foo/my.jpg', $userFile->getUrl());
     $userFile = new CM_File_UserContent('bar', 'my.jpg', null, $serviceManager);
     $this->assertSame('http://example.com/default/bar/my.jpg', $userFile->getUrl());
 }
예제 #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);
 }
예제 #3
0
 /**
  * @param CM_File_UserContent $file
  * @return string
  */
 public function getUrlUserContent(CM_File_UserContent $file)
 {
     return $file->getUrl();
 }
예제 #4
0
파일: Temp.php 프로젝트: NicolasSchmutz/cm
 public function delete($recursive = null)
 {
     CM_Db_Db::delete('cm_tmp_userfile', array('uniqid' => $this->getUniqid()));
     parent::delete();
 }
예제 #5
0
파일: Video.php 프로젝트: NicolasSchmutz/cm
 protected function _onDeleteBefore()
 {
     $this->getVideo()->delete();
     $thumbnailDir = new CM_File_UserContent('streamChannels', $this->getId() . '-' . $this->getHash() . '-thumbs/', $this->getId());
     $thumbnailDir->delete(true);
 }
예제 #6
0
파일: Media.php 프로젝트: cargomedia/cm
 protected function _onDeleteBefore()
 {
     if ($this->hasFile()) {
         $this->getFile()->delete();
     }
     $thumbnailDir = new CM_File_UserContent('streamChannels', $this->getId() . '-thumbs', $this->getId());
     $thumbnailDir->delete(true);
     /** @var CM_StreamChannel_Thumbnail $thumbnail */
     foreach ($this->getThumbnails() as $thumbnail) {
         $thumbnail->delete();
     }
 }