當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。