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


PHP MediaInterface::getProviderName方法代码示例

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


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

示例1: resize

 /**
  * {@inheritdoc}
  */
 public function resize(MediaInterface $media, File $in, File $out, $format, array $settings)
 {
     if (!isset($settings['width'])) {
         throw new \RuntimeException(sprintf('Width parameter is missing in context "%s" for provider "%s"', $media->getContext(), $media->getProviderName()));
     }
     $image = $this->adapter->load($in->getContent());
     $size = $media->getBox();
     if (null != $settings['height']) {
         if ($size->getHeight() > $size->getWidth()) {
             $higher = $size->getHeight();
             $lower = $size->getWidth();
         } else {
             $higher = $size->getWidth();
             $lower = $size->getHeight();
         }
         $crop = $higher - $lower;
         if ($crop > 0) {
             $point = $higher == $size->getHeight() ? new Point(0, 0) : new Point($crop / 2, 0);
             $image->crop($point, new Box($lower, $lower));
             $size = $image->getSize();
         }
     }
     $settings['height'] = (int) ($settings['width'] * $size->getHeight() / $size->getWidth());
     if ($settings['height'] < $size->getHeight() && $settings['width'] < $size->getWidth()) {
         $content = $image->thumbnail(new Box($settings['width'], $settings['height']), $this->mode)->get($format, array('quality' => $settings['quality']));
     } else {
         $content = $image->get($format, array('quality' => $settings['quality']));
     }
     $out->setContent($content, $this->metadata->get($media, $out->getName()));
 }
开发者ID:ingeniorweb,项目名称:symfo3cv,代码行数:33,代码来源:SquareResizer.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: getBox

 /**
  * {@inheritdoc}
  */
 public function getBox(MediaInterface $media, array $settings)
 {
     $size = $media->getBox();
     if ($settings['width'] == null && $settings['height'] == null) {
         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 ($settings['height'] == null) {
         $settings['height'] = (int) ($settings['width'] * $size->getHeight() / $size->getWidth());
     }
     if ($settings['width'] == null) {
         $settings['width'] = (int) ($settings['height'] * $size->getWidth() / $size->getHeight());
     }
     return $this->computeBox($media, $settings);
 }
开发者ID:nicolasricci,项目名称:SonataMediaBundle,代码行数:17,代码来源:SimpleResizer.php

示例4: getAmazonBuilder

 /**
  * @param MediaInterface $metadata
  * @param string         $filename
  *
  * @return array
  */
 protected function getAmazonBuilder(MediaInterface $media, $filename)
 {
     $adapter = $this->container->get($media->getProviderName())->getFilesystem()->getAdapter();
     //handle special Replicate adapter
     if ($adapter instanceof Replicate) {
         $adapterClassNames = $adapter->getAdapterClassNames();
     } else {
         $adapterClassNames = array(get_class($adapter));
     }
     //for amazon s3
     if (!in_array('Gaufrette\\Adapter\\AmazonS3', $adapterClassNames) || !$this->container->has('sonata.media.metadata.amazon')) {
         return false;
     }
     return $this->container->get('sonata.media.metadata.amazon')->get($media, $filename);
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:21,代码来源:ProxyMetadataBuilder.php

示例5: getBox

 /**
  * {@inheritdoc}
  */
 public function getBox(MediaInterface $media, array $settings)
 {
     $size = $media->getBox();
     $hasWidth = isset($settings['width']) && $settings['width'];
     $hasHeight = isset($settings['height']) && $settings['height'];
     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) {
         return new Box($settings['width'], $settings['height']);
     }
     if (!$hasHeight) {
         $settings['height'] = intval($settings['width'] * $size->getHeight() / $size->getWidth());
     }
     if (!$hasWidth) {
         $settings['width'] = intval($settings['height'] * $size->getWidth() / $size->getHeight());
     }
     return $this->computeBox($media, $settings);
 }
开发者ID:NadirZenith,项目名称:NzSonataMediaBundle,代码行数:22,代码来源:FixCropResizer.php

示例6: getProvider

 /**
  * @param MediaInterface $media
  *
  * @return MediaProviderInterface
  */
 private function getProvider(MediaInterface $media)
 {
     return $this->pool->getProvider($media->getProviderName());
 }
开发者ID:nandorstanko,项目名称:SonataMediaBundle,代码行数:9,代码来源:MediaHelper.php

示例7: getProvider

 /**
  * @param MediaInterface $media
  *
  * @return MediaProviderInterface
  */
 public function getProvider(MediaInterface $media)
 {
     return $this->get('sonata.media.pool')->getProvider($media->getProviderName());
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:9,代码来源:MediaController.php

示例8: validate

 /**
  * @param \Sonata\CoreBundle\Validator\ErrorElement $errorElement
  * @param \Sonata\MediaBundle\Model\MediaInterface  $media
  */
 public function validate(ErrorElement $errorElement, MediaInterface $media)
 {
     if (!$media->getProviderName()) {
         return;
     }
     $provider = $this->getProvider($media->getProviderName());
     $provider->validate($errorElement, $media);
 }
开发者ID:Infernosquad,项目名称:SonataMediaBundle,代码行数:12,代码来源:Pool.php

示例9: addImageInfo

 /**
  * @param MediaInterface   $image
  * @param SeoPageInterface $seoPage
  */
 protected function addImageInfo(MediaInterface $image, SeoPageInterface $seoPage)
 {
     $provider = $this->mediaPool->getProvider($image->getProviderName());
     $seoPage->addMeta('property', 'og:image', $provider->generatePublicUrl($image, $this->mediaFormat))->addMeta('property', 'og:image:width', $image->getWidth())->addMeta('property', 'og:image:height', $image->getHeight())->addMeta('property', 'og:image:type', $image->getContentType());
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:9,代码来源:Facebook.php

示例10: path

    /**
     * @param \Sonata\MediaBundle\Model\MediaInterface $media
     * @param string $format
     * @return string
     */
    public function path(MediaInterface $media = null, $format)
    {
        if (!$media) {
             return '';
        }

        $provider = $this->getMediaService()
           ->getProvider($media->getProviderName());

        return $provider->generatePublicUrl($media, $format);
    }
开发者ID:ronnylt,项目名称:MediaBundle,代码行数:16,代码来源:MediaExtension.php


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