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


PHP BlockContextInterface::setSetting方法代码示例

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


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

示例1: execute

 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     $settings = $blockContext->getSettings();
     $photos = $this->em->getRepository('AldorPortfolioBundle:Project')->getRecent($settings['max']);
     $imageSize = 'medium';
     if ($this->deviceDetector->isMobile()) {
         $imageSize = 'small';
         $blockContext->setSetting('extra_cache_key', 'mobile');
     }
     return $this->renderResponse($blockContext->getTemplate(), array('entities' => $photos, 'title' => $settings['title'], 'imageSize' => $imageSize), $response);
 }
开发者ID:Aldor007,项目名称:mkaciuba.pl,代码行数:11,代码来源:RecentProjectsBlockService.php

示例2: execute

 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     $settings = $blockContext->getSettings();
     if ($settings['category']) {
         $posts = $this->em->getRepository('AldorBlogBundle:Post')->getRecentPostsFromCategory($settings['category'], $settings['max']);
     } else {
         $posts = $this->em->getRepository('AldorBlogBundle:Post')->getRecentPosts($settings['max']);
     }
     $imagesSize = ['big', 'medium'];
     if ($this->deviceDetector->isMobile()) {
         $imagesSize = ['medium', 'medium'];
         $blockContext->setSetting('extra_cache_key', 'mobile');
     }
     return $this->renderResponse($blockContext->getTemplate(), array('imagesSize' => $imagesSize, 'posts' => $posts, 'title' => $settings['title'], 'category' => $settings['category']), $response);
 }
开发者ID:Aldor007,项目名称:mkaciuba.pl,代码行数:15,代码来源:RecentPostsBlockService.php

示例3: execute

 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     $settings = $blockContext->getSettings();
     $gallery = $this->em->getRepository('AldorGalleryBundle:Gallery')->findOneBySlug($settings['gallery']);
     $photos = array();
     if ($gallery) {
         $categories = $gallery->getCategories();
         $photos = $this->em->getRepository('AldorGalleryBundle:Photo')->getRecentFromGallery($categories, $gallery->getId(), $settings['max']);
     }
     $imageSize = 'medium';
     if ($this->deviceDetector->isMobile()) {
         $imageSize = 'big200';
         $blockContext->setSetting('extra_cache_key', 'mobile');
     }
     return $this->renderResponse($blockContext->getTemplate(), array('entities' => $photos, 'title' => $settings['title'] . ' z galerii ' . $settings['gallery'], 'active' => $settings['active'], 'gallery' => $gallery, 'imageSize' => $imageSize), $response);
 }
开发者ID:Aldor007,项目名称:mkaciuba.pl,代码行数:16,代码来源:RecentPhotoBlockService.php

示例4: getMenu

 /**
  * {@inheritdoc}
  */
 protected function getMenu(BlockContextInterface $blockContext)
 {
     $blockContext->setSetting('include_homepage_link', false);
     $menu = $this->getRootMenu($blockContext);
     $page = $this->getCurrentPage();
     if (!$page) {
         return $menu;
     }
     $parents = $page->getParents();
     foreach ($parents as $parent) {
         if ($parent->isError()) {
             continue;
         }
         $menu->addChild($parent->getName(), array('route' => 'page_slug', 'routeParameters' => array('path' => $parent->getUrl())));
     }
     if (!$page->isError()) {
         $menu->addChild($page->getName(), array('route' => 'page_slug', 'routeParameters' => array('path' => $page->getUrl())));
     }
     return $menu;
 }
开发者ID:TomasVotruba,项目名称:SonataPageBundle,代码行数:23,代码来源:BreadcrumbBlockService.php

示例5: setDefaultExtraCacheKeys

 /**
  * Adds context settings, to be able to rebuild a block context, to the
  * extra_cache_keys
  *
  * @param BlockContextInterface $blockContext
  * @param array $settings
  */
 protected function setDefaultExtraCacheKeys(BlockContextInterface $blockContext, array $settings)
 {
     if (!$blockContext->getSetting('use_cache') || $blockContext->getSetting('ttl') <= 0) {
         return;
     }
     $block = $blockContext->getBlock();
     // type by block class
     $class = ClassUtils::getClass($block);
     $cacheServiceId = isset($this->cacheBlocks['by_class'][$class]) ? $this->cacheBlocks['by_class'][$class] : false;
     // type by block service
     if (!$cacheServiceId) {
         $cacheServiceId = isset($this->cacheBlocks['by_type'][$block->getType()]) ? $this->cacheBlocks['by_type'][$block->getType()] : false;
     }
     if (!$cacheServiceId) {
         // no context cache needed
         return;
     }
     // do not add cache settings to extra_cache_keys
     unset($settings['use_cache'], $settings['extra_cache_keys'], $settings['ttl']);
     $extraCacheKeys = $blockContext->getSetting('extra_cache_keys');
     // add context settings to extra_cache_keys
     if (!isset($extraCacheKeys[self::CACHE_KEY])) {
         $extraCacheKeys[self::CACHE_KEY] = $settings;
         $blockContext->setSetting('extra_cache_keys', $extraCacheKeys);
     }
 }
开发者ID:LamaDelRay,项目名称:test_symf,代码行数:33,代码来源:BlockContextManager.php

示例6: execute

 /**
  * {@inheritdoc}
  */
 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     // make sure we have a valid format
     $media = $blockContext->getBlock()->getSetting('mediaId');
     if ($media instanceof MediaInterface) {
         $choices = $this->getFormatChoices($media);
         if (!array_key_exists($blockContext->getSetting('format'), $choices)) {
             $blockContext->setSetting('format', key($choices));
         }
     }
     return $this->renderResponse($blockContext->getTemplate(), array('media' => $blockContext->getSetting('mediaId'), 'block' => $blockContext->getBlock(), 'settings' => $blockContext->getSettings()), $response);
 }
开发者ID:elvetemedve,项目名称:SonataMediaBundle,代码行数:15,代码来源:MediaBlockService.php

示例7: execute

 /**
  * {@inheritdoc}
  */
 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     $settings = $blockContext->getSettings();
     $repository = $this->em->getRepository('KinkinwebLhvbBundle:Bureau');
     $data = $repository->findAll();
     // make sure we have a valid format
     $media = $blockContext->getBlock()->getSetting('mediaId');
     if ($media instanceof MediaInterface) {
         $choices = $this->getFormatChoices($media);
         if (!array_key_exists($blockContext->getSetting('format'), $choices)) {
             $blockContext->setSetting('format', key($choices));
         }
     }
     if (!empty($data)) {
         $bureau = $data[0];
     } else {
         $bureau = null;
     }
     return $this->renderResponse($blockContext->getTemplate(), array('bureau' => $bureau, 'media' => $blockContext->getSetting('mediaId'), 'block' => $blockContext->getBlock(), 'settings' => $blockContext->getSettings()), $response);
 }
开发者ID:kinkinweb,项目名称:lhvb,代码行数:23,代码来源:BureauBlockService.php


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