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


PHP MediaInterface::getId方法代码示例

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


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

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

示例4: generate

 /**
  * {@inheritdoc}
  */
 public function generate(MediaProviderInterface $provider, MediaInterface $media)
 {
     $backend = $this->backend;
     $id = $this->id;
     $publish = function () use($backend, $media, $id) {
         $backend->createAndPublish('sonata.media.create_thumbnail', array('thumbnailId' => $id, 'mediaId' => $media->getId(), 'providerReference' => $media->getProviderReference()));
     };
     // BC compatibility for missing EventDispatcher
     if (null === $this->dispatcher) {
         trigger_error('Since version 2.3.3, passing an empty parameter in argument 4 for __construct() in ' . __CLASS__ . ' is deprecated and the workaround for it will be removed in 3.0.', E_USER_DEPRECATED);
         $publish();
     } else {
         $this->dispatcher->addListener('kernel.finish_request', $publish);
     }
 }
开发者ID:nicolasricci,项目名称:SonataMediaBundle,代码行数:18,代码来源:ConsumerThumbnail.php

示例5: flushCdn

 /**
  * @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);
         }
     }
 }
开发者ID:ricoli,项目名称:SonataMediaBundle,代码行数:20,代码来源:BaseProvider.php

示例6: processMedia

 /**
  * @param MediaInterface         $media
  * @param MediaProviderInterface $provider
  * @param string                 $context
  * @param string                 $format
  *
  * @return bool
  */
 protected function processMedia(MediaInterface $media, MediaProviderInterface $provider, $context, $format)
 {
     $this->log('Deleting thumbs for ' . $media->getName() . ' - ' . $media->getId());
     try {
         if ($format === $context . '_all') {
             $format = null;
         }
         $provider->removeThumbnails($media, $format);
     } catch (\Exception $e) {
         $this->log(sprintf('<error>Unable to remove thumbnails, media: %s - %s </error>', $media->getId(), $e->getMessage()));
         return false;
     }
     return true;
 }
开发者ID:ipalo,项目名称:SonataMediaBundle,代码行数:22,代码来源:RemoveThumbsCommand.php

示例7: generateHash

 /**
  * @param MediaInterface $media
  *
  * @return string
  */
 private function generateHash(MediaInterface $media)
 {
     return sha1($media->getId() . $media->getCreatedAt()->format('u') . $this->secret);
 }
开发者ID:nandorstanko,项目名称:SonataMediaBundle,代码行数:9,代码来源:Pixlr.php

示例8: generatePath

 /**
  * {@inheritdoc}
  */
 public function generatePath(MediaInterface $media)
 {
     $id = $media->getId();
     return sprintf('%s/%04s/%02s', $media->getContext(), substr($id, 0, 4), substr($id, 4, 2));
 }
开发者ID:ipalo,项目名称:SonataMediaBundle,代码行数:8,代码来源:ODMGenerator.php

示例9: generate

 /**
  * {@inheritdoc}
  */
 public function generate(MediaProviderInterface $provider, MediaInterface $media)
 {
     $this->backend->createAndPublish('sonata.media.create_thumbnail', array('thumbnailId' => $this->id, 'mediaId' => $media->getId(), 'providerReference' => $media->getProviderReference()));
 }
开发者ID:nandorstanko,项目名称:SonataMediaBundle,代码行数:7,代码来源:ConsumerThumbnail.php

示例10: generatePublicUrl

 /**
  * @param MediaInterface $media
  * @param string         $format
  *
  * @return string
  * @internal param Router $router
  */
 public function generatePublicUrl(MediaInterface $media, $format)
 {
     return $this->router->generate('ticket_get_big_img', ['format' => $format, 'id' => $media->getId()]);
 }
开发者ID:dreamlex,项目名称:ticketbundle,代码行数:11,代码来源:TicketImageProvider.php

示例11: processMedia

 /**
  * @param MediaInterface         $media
  * @param MediaProviderInterface $provider
  *
  * @return bool
  */
 protected function processMedia($media, $provider)
 {
     $this->log('Generating thumbs for ' . $media->getName() . ' - ' . $media->getId());
     try {
         $provider->removeThumbnails($media);
     } catch (\Exception $e) {
         $this->log(sprintf('<error>Unable to remove old thumbnails, media: %s - %s </error>', $media->getId(), $e->getMessage()));
         return false;
     }
     try {
         $provider->generateThumbnails($media);
     } catch (\Exception $e) {
         $this->log(sprintf('<error>Unable to generate new thumbnails, media: %s - %s </error>', $media->getId(), $e->getMessage()));
         return false;
     }
     return true;
 }
开发者ID:nicolasricci,项目名称:SonataMediaBundle,代码行数:23,代码来源:SyncThumbsCommand.php

示例12: generateThumbnails

 public function generateThumbnails(MediaInterface $media)
 {
     $this->producer->produce(self::QUEUE_NAME, ['id' => $media->getId()]);
 }
开发者ID:sergeym,项目名称:videque-bundle,代码行数:4,代码来源:VidequeProvider.php


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