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


PHP Model\MediaInterface类代码示例

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


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

示例1: generatePath

    /**
     * @abstract
     * @param \Sonata\MediaBundle\Model\MediaInterface $media
     * @return string
     */
    public function generatePath(MediaInterface $media)
    {
        $rep_first_level = (int) ($media->getId() / $this->firstLevel);
        $rep_second_level = (int) (($media->getId() - ($rep_first_level * $this->firstLevel)) / $this->secondLevel);

        return sprintf('%s/%04s/%02s', $media->getContext(), $rep_first_level + 1, $rep_second_level + 1);
    }
开发者ID:ronnylt,项目名称:MediaBundle,代码行数:12,代码来源:DefaultGenerator.php

示例2: getBox

 /**
  * {@inheritdoc}
  */
 public function getBox(MediaInterface $media, array $settings)
 {
     $size = $media->getBox();
     $skipBox = false;
     $constraint = array_key_exists('constraint', $settings) && $settings['constraint'] === false;
     if ($constraint && $size->getHeight() > $size->getWidth()) {
         $settings['width'] = $settings['height'];
         $this->mode = ImageInterface::THUMBNAIL_INSET;
         $skipBox = true;
     }
     $hasWidth = array_key_exists('width', $settings) && $settings['width'] > 0;
     $hasHeight = array_key_exists('height', $settings) && $settings['height'] > 0;
     if (!$hasWidth && !$hasHeight) {
         throw new \RuntimeException(sprintf('Width/Height parameter is missing in context "%s" for provider "%s". Please add at least one parameter.', $media->getContext(), $media->getProviderName()));
     }
     if ($hasWidth && $hasHeight && !$skipBox) {
         return new Box($settings['width'], $settings['height']);
     }
     if (!$hasHeight) {
         $settings['height'] = (int) ($settings['width'] * $size->getHeight() / $size->getWidth());
     }
     if (!$hasWidth) {
         $settings['width'] = (int) ($settings['height'] * $size->getWidth() / $size->getHeight());
     }
     return $this->computeBox($size, $settings);
 }
开发者ID:zapoyok,项目名称:core-bundle,代码行数:29,代码来源:ScaleCropResizer.php

示例3: save

 /**
  * Updates a media
  *
  * @param \Sonata\MediaBundle\Model\MediaInterface $media
  * @param string $context
  * @param string $providerName
  * @return void
  */
 public function save(MediaInterface $media, $context = null, $providerName = null)
 {
     if ($context) {
         $media->setContext($context);
     }
     if ($providerName) {
         $media->setProviderName($providerName);
     }
     $isNew = $media->getId() != null;
     if ($isNew) {
         $this->pool->getProvider($media->getProviderName())->prePersist($media);
     } else {
         $this->pool->getProvider($media->getProviderName())->preUpdate($media);
     }
     $this->dm->persist($media);
     $this->dm->flush();
     if ($isNew) {
         $this->pool->getProvider($media->getProviderName())->postPersist($media);
     } else {
         $this->pool->getProvider($media->getProviderName())->postUpdate($media);
     }
     // just in case the pool alter the media
     $this->dm->persist($media);
     $this->dm->flush();
 }
开发者ID:novatex,项目名称:SonataMediaBundle,代码行数:33,代码来源:MediaManager.php

示例4: getExtension

 /**
  * @param \Sonata\MediaBundle\Model\MediaInterface $media
  *
  * @return string the file extension for the $media, or the $defaultExtension if not available
  */
 protected function getExtension(MediaInterface $media)
 {
     $ext = $media->getExtension();
     if (!is_string($ext) || strlen($ext) < 3) {
         $ext = $this->defaultFormat;
     }
     return $ext;
 }
开发者ID:novatex,项目名称:SonataMediaBundle,代码行数:13,代码来源:FormatThumbnail.php

示例5: fixBinaryContent

 /**
  * @param MediaInterface $media
  */
 protected function fixBinaryContent(MediaInterface $media)
 {
     if (!$media->getBinaryContent()) {
         return;
     }
     if (preg_match("/www.dailymotion.com\\/video\\/([0-9a-zA-Z]*)_/", $media->getBinaryContent(), $matches)) {
         $media->setBinaryContent($matches[1]);
     }
 }
开发者ID:nicolasricci,项目名称:SonataMediaBundle,代码行数:12,代码来源:DailyMotionProvider.php

示例6: fixBinaryContent

 /**
  * @param MediaInterface $media
  */
 protected function fixBinaryContent(MediaInterface $media)
 {
     if (!$media->getBinaryContent()) {
         return;
     }
     if (preg_match("/vimeo\\.com\\/(video\\/|)(\\d+)/", $media->getBinaryContent(), $matches)) {
         $media->setBinaryContent($matches[2]);
     }
 }
开发者ID:nicolasricci,项目名称:SonataMediaBundle,代码行数:12,代码来源:VimeoProvider.php

示例7: 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

示例8: getHelperProperties

    public function getHelperProperties(MediaInterface $media, $format, $options = array())
    {
        $format_configuration = $this->getFormat($format);

        return array_merge(array(
          'title'    => $media->getName(),
          'src'      => $this->generatePublicUrl($media, $format),
          'width'    => $format_configuration['width'],
        ), $options);
    }
开发者ID:ronnylt,项目名称:MediaBundle,代码行数:10,代码来源:ImageProvider.php

示例9: getRootCategory

 /**
  * @param MediaInterface $media
  *
  * @return mixed
  */
 protected function getRootCategory(MediaInterface $media)
 {
     if (!$this->rootCategories) {
         $this->rootCategories = $this->container->get('sonata.classification.manager.category')->getRootCategories(false);
     }
     if (!array_key_exists($media->getContext(), $this->rootCategories)) {
         throw new \RuntimeException(sprintf('There is no main category related to context: %s', $media->getContext()));
     }
     return $this->rootCategories[$media->getContext()];
 }
开发者ID:rmzamora,项目名称:SonataMediaBundle,代码行数:15,代码来源:MediaEventSubscriber.php

示例10: getHelperProperties

 /**
  * {@inheritdoc}
  */
 public function getHelperProperties(MediaInterface $media, $format, $options = array())
 {
     /*$getId3 = new GetId3();
       $audio = $getId3
           ->setOptionMD5Data(true)
           ->setOptionMD5DataSource(true)
           ->setEncoding('UTF-8')
           ->analyze($this->root_dir . '/../web' .$this->generatePublicUrl($media, $format))
       ;*/
     return array_merge(array('name' => $media->getName(), 'src' => $this->generatePublicUrl($media, $format), 'filesize' => $media->getMetadataValue('filesize'), 'fileformat' => $media->getMetadataValue('fileformat'), 'encoding' => $media->getMetadataValue('encoding'), 'mime_type' => $media->getMetadataValue('mime_type'), 'playtime_seconds' => $media->getMetadataValue('playtime_seconds'), 'playtime_string' => $media->getMetadataValue('playtime_string'), 'bitrate' => $media->getMetadataValue('bitrate'), 'audio_dataformat' => $media->getMetadataValue('audio_dataformat'), 'audio_codec' => $media->getMetadataValue('audio_codec'), 'audio_sample_rate' => $media->getMetadataValue('audio_sample_rate'), 'audio_channels' => $media->getMetadataValue('audio_channels'), 'audio_bits_per_sample' => $media->getMetadataValue('audio_bits_per_sample'), 'audio_lossless' => $media->getMetadataValue('audio_lossless'), 'audio_channelmode' => $media->getMetadataValue('audio_channelmode'), 'video_dataformat' => $media->getMetadataValue('video_dataformat'), 'video_resolution_x' => $media->getMetadataValue('video_resolution_x'), 'video_resolution_y' => $media->getMetadataValue('video_resolution_y'), 'video_fourcc' => $media->getMetadataValue('video_fourcc'), 'video_frame_rate' => $media->getMetadataValue('video_frame_rate'), 'video_codec' => $media->getMetadataValue('video_codec')), $options);
 }
开发者ID:estebannovo,项目名称:multimedia,代码行数:14,代码来源:VideoProvider.php

示例11: getFormatName

 public function getFormatName(MediaInterface $media, $format)
 {
     if (in_array($format, array('admin', 'reference', 'orangegate'))) {
         return $format;
     }
     $baseName = $media->getContext() . '_';
     if (substr($format, 0, strlen($baseName)) == $baseName) {
         return $format;
     }
     return $baseName . str_replace('-', '_', $format);
 }
开发者ID:symbio,项目名称:orangegate4-media-bundle,代码行数:11,代码来源:ImageProvider.php

示例12: createQrCode

 protected function createQrCode(MediaInterface $media)
 {
     $path = tempnam(sys_get_temp_dir(), 'sonata_media_qrcode_reference') . '.' . $this->config['extension'];
     $qrCode = new QrCode();
     $qrCode->setText($media->getBinaryContent())->setSize($this->config['size'])->setPadding($this->config['padding'])->setErrorCorrection($this->config['error_correction'])->setForegroundColor($this->config['foreground'])->setBackgroundColor($this->config['background'])->setLabel($this->config['label'])->setLabelFontSize($this->config['label_size'])->setImageType($this->config['extension']);
     if ($this->config['logo'] && is_file($this->config['logo'])) {
         $qrCode->setLogo($this->config['logo']);
     }
     $qrCode->save($path);
     return $path;
 }
开发者ID:NadirZenith,项目名称:NzSonataMediaBundle,代码行数:11,代码来源:QrCodeProvider.php

示例13: save

 /**
  * {@inheritdoc}
  */
 public function save(MediaInterface $media, $context = null, $providerName = null)
 {
     if ($context) {
         $media->setContext($context);
     }
     if ($providerName) {
         $media->setProviderName($providerName);
     }
     // just in case the pool alter the media
     $this->em->persist($media);
     $this->em->flush();
 }
开发者ID:novatex,项目名称:SonataMediaBundle,代码行数:15,代码来源:MediaManager.php

示例14: fixBinaryContent

 /**
  * {@inheritdoc}
  */
 protected function fixBinaryContent(MediaInterface $media)
 {
     if (!$media->getBinaryContent()) {
         return;
     }
     if (strlen($media->getBinaryContent()) === 11) {
         return;
     }
     if (preg_match("/^(?:http(?:s)?:\\/\\/)?(?:www\\.)?(?:youtu\\.be\\/|youtube\\.com\\/(?:(?:watch)?\\?(?:.*&)?v(?:i)?=|(?:embed|v|vi|user)\\/))([^\\#\\?&\"'>]+)/", $media->getBinaryContent(), $matches)) {
         $media->setBinaryContent($matches[1]);
     }
 }
开发者ID:rapemer,项目名称:init-cms-bundle,代码行数:15,代码来源:YouTubeProvider.php

示例15: generatePath

 /**
  * @param \Sonata\MediaBundle\Model\MediaInterface $media
  *
  * @return string
  */
 public function generatePath(MediaInterface $media)
 {
     $segments = preg_split('#/#', $media->getId(), null, PREG_SPLIT_NO_EMPTY);
     if (count($segments) > 1) {
         // remove last part from id
         array_pop($segments);
         $path = join($segments, '/');
     } else {
         $path = '';
     }
     return $path ? sprintf('%s/%s', $media->getContext(), $path) : $media->getContext();
 }
开发者ID:serialken,项目名称:BugTracker,代码行数:17,代码来源:PHPCRGenerator.php


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