当前位置: 首页>>代码示例>>PHP>>正文


PHP MediaInterface::getMetadataValue方法代码示例

本文整理汇总了PHP中Sonata\MediaBundle\Model\MediaInterface::getMetadataValue方法的典型用法代码示例。如果您正苦于以下问题:PHP MediaInterface::getMetadataValue方法的具体用法?PHP MediaInterface::getMetadataValue怎么用?PHP MediaInterface::getMetadataValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sonata\MediaBundle\Model\MediaInterface的用法示例。


在下文中一共展示了MediaInterface::getMetadataValue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getReferenceImage

 /**
  * Replace 4/3 by 16/9 format
  * Possible Formats :
  * default
  * mqdefault -> medium quality
  * hqdefault -> high quality
  * sddefault
  * maxresdefault
  *
  * {@inheritdoc}
  */
 public function getReferenceImage(MediaInterface $media)
 {
     $url = $media->getMetadataValue('thumbnail_url');
     $pattern = '/\\bhqdefault\\b/i';
     $sddefault_url = preg_replace($pattern, 'sddefault', $url);
     //var_dump($sddefault_url);
     //exit();
     return $sddefault_url;
 }
开发者ID:gautierJ,项目名称:imh-website,代码行数:20,代码来源:CustomYouTubeProvider.php

示例2: getReferenceImage

 /**
  * {@inheritdoc}
  */
 public function getReferenceImage(MediaInterface $media)
 {
     return $media->getMetadataValue('thumbnail_url');
 }
开发者ID:novatex,项目名称:SonataMediaBundle,代码行数:7,代码来源:BaseVideoProvider.php

示例3: getDownloadResponse

 /**
  * {@inheritdoc}
  */
 public function getDownloadResponse(MediaInterface $media, $format, $mode, array $headers = array())
 {
     // build the default headers
     $headers = array_merge(array('Content-Type' => $media->getContentType(), 'Content-Disposition' => sprintf('attachment; filename="%s"', $media->getMetadataValue('filename'))), $headers);
     if (!in_array($mode, array('http', 'X-Sendfile', 'X-Accel-Redirect'))) {
         throw new \RuntimeException('Invalid mode provided');
     }
     if ($mode == 'http') {
         if ($format == 'reference') {
             $file = $this->getReferenceFile($media);
         } else {
             $file = $this->getFilesystem()->get($this->generatePrivateUrl($media, $format));
         }
         return new StreamedResponse(function () use($file) {
             echo $file->getContent();
         }, 200, $headers);
     }
     if (!$this->getFilesystem()->getAdapter() instanceof \Sonata\MediaBundle\Filesystem\Local) {
         throw new \RuntimeException('Cannot use X-Sendfile or X-Accel-Redirect with non \\Sonata\\MediaBundle\\Filesystem\\Local');
     }
     $filename = sprintf('%s/%s', $this->getFilesystem()->getAdapter()->getDirectory(), $this->generatePrivateUrl($media, $format));
     return new BinaryFileResponse($filename, 200, $headers);
 }
开发者ID:kea,项目名称:SonataMediaBundle,代码行数:26,代码来源:FileProvider.php

示例4: getReferenceImage

 /**
  * {@inheritdoc}
  */
 public function getReferenceImage(MediaInterface $media)
 {
     $content = $media->getMetadataValue('content');
     return $content['poster'];
 }
开发者ID:NadirZenith,项目名称:NzSonataMediaBundle,代码行数:8,代码来源:PlayWireProvider.php

示例5: getDownloadResponse

 /**
  * {@inheritdoc}
  */
 public function getDownloadResponse(MediaInterface $media, $format, $mode, array $headers = array())
 {
     // build the default headers
     $headers = array_merge(array('Content-Type' => $media->getContentType(), 'Content-Disposition' => sprintf('attachment; filename="%s"', $media->getMetadataValue('filename'))), $headers);
     if (!in_array($mode, array('http', 'X-Sendfile', 'X-Accel-Redirect'))) {
         throw new \RuntimeException('Invalid mode provided');
     }
     if ($mode == 'http') {
         $provider = $this;
         return new StreamedResponse(function () use($provider, $media) {
             echo $provider->getReferenceFile($media)->getContent();
         }, 200, $headers);
     }
     $headers[$mode] = $this->generatePrivateUrl($media, $format);
     return new Response('', 200, $headers);
 }
开发者ID:novatex,项目名称:SonataMediaBundle,代码行数:19,代码来源:FileProvider.php

示例6: generateReferenceSlug

 protected function generateReferenceSlug(MediaInterface $media)
 {
     $filename = $media->getMetadataValue('filename');
     $extension = substr($filename, strrpos($filename, '.') + 1);
     return (new Slugify())->slugify(substr($filename, 0, strlen($filename) - strlen($extension)));
 }
开发者ID:symbio,项目名称:orangegate4-media-bundle,代码行数:6,代码来源:FileProvider.php

示例7: getDownloadResponse

 /**
  * {@inheritdoc}
  */
 public function getDownloadResponse(MediaInterface $media, $format, $mode = null, array $headers = array())
 {
     $headers = array_merge(array('Content-Type' => $media->getContentType(), 'Content-Disposition' => sprintf('attachment; filename="%s"', $media->getMetadataValue('filename'))), $headers);
     // create default variables
     if ($mode == 'X-Sendfile') {
         $headers['X-Sendfile'] = $this->generatePrivateUrl($media, $format);
         $content = '';
     } elseif ($mode == 'X-Accel-Redirect') {
         $headers['X-Accel-Redirect'] = $this->generatePrivateUrl($media, $format);
         $content = '';
     } elseif ($mode == 'http') {
         $content = $this->getReferenceFile($media)->getContent();
     } else {
         $content = '';
     }
     return new Response($content, 200, $headers);
 }
开发者ID:polypodes,项目名称:EuradioNantes.eu,代码行数:20,代码来源:PodcastProvider_bak.php


注:本文中的Sonata\MediaBundle\Model\MediaInterface::getMetadataValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。