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);
 }
 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);
 }
 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);
 }
 /**
  * {@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;
 }
 /**
  * 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);
     }
 }
 /**
  * {@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);
 }
Beispiel #7
0
 /**
  * {@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);
 }