コード例 #1
0
 /**
  * @param MediaInterface $media
  */
 public function flushCdn(MediaInterface $media)
 {
     if ($media->getId() && $this->requireThumbnails() && !$media->getCdnIsFlushable()) {
         $flushPaths = array();
         foreach ($this->getFormats() as $format => $settings) {
             if ('admin' === $format || substr($format, 0, strlen($media->getContext())) === $media->getContext()) {
                 $flushPaths[] = $this->getFilesystem()->get($this->generatePrivateUrl($media, $format), true)->getKey();
             }
         }
         if (!empty($flushPaths)) {
             $cdnFlushIdentifier = $this->getCdn()->flushPaths($flushPaths);
             $media->setCdnFlushIdentifier($cdnFlushIdentifier);
             $media->setCdnIsFlushable(true);
             $media->setCdnStatus(CDNInterface::STATUS_TO_FLUSH);
         }
     }
 }
コード例 #2
0
ファイル: FileProvider.php プロジェクト: ronnylt/MediaBundle
 /**
  * @param \Sonata\MediaBundle\Model\MediaInterface $media
  * @param string $format
  * @return string
  */
 public function generatePublicUrl(MediaInterface $media, $format)
 {
     // todo: add a valid icon set
     return $this->getCdn()->getPath(sprintf('media_bundle/images/files/%s/file.png', $format), $media->getCdnIsFlushable());
 }
コード例 #3
0
 /**
  * @param MediaInterface $media
  *
  * @return string
  * @internal param $format
  */
 public function generateProtectedUrl(MediaInterface $media)
 {
     return $this->getCdn()->getPath($media->getId(), $media->getCdnIsFlushable());
 }