/** * {@inheritdoc} */ public function execute(BlockContextInterface $blockContext, Response $response = null) { $context = $blockContext->getBlock()->getSetting('context'); $criteria = array('mode' => $blockContext->getSetting('mode'), 'context' => $context); $order = array($blockContext->getSetting('order') => $blockContext->getSetting('sort')); return $this->renderResponse($blockContext->getTemplate(), array('context' => $blockContext, 'settings' => $blockContext->getSettings(), 'block' => $blockContext->getBlock(), 'pager' => $this->galleryManager->getPager($criteria, 1, $blockContext->getSetting('number'), $order)), $response); }
/** * {@inheritdoc} */ public function execute(BlockContextInterface $blockContext, Response $response = null) { $criteria = array(); if ('admin' !== $blockContext->getSetting('mode')) { $criteria['customer'] = $this->customerManager->findOneBy(array('user' => $this->securityContext->getToken()->getUser())); } return $this->renderPrivateResponse($blockContext->getTemplate(), array('context' => $blockContext, 'settings' => $blockContext->getSettings(), 'block' => $blockContext->getBlock(), 'orders' => $this->orderManager->findBy($criteria, array('createdAt' => 'DESC'), $blockContext->getSetting('number'))), $response); }
/** * {@inheritdoc} */ public function execute(BlockContextInterface $blockContext, Response $response = null) { $criteria = array('mode' => $blockContext->getSetting('mode')); $userManager = $this->container->get('fos_user.user_manager'); $user = $userManager->findUserByUsername($this->container->get('security.context')->getToken()->getUser()); $mapbookmarks = null; $ecosystems = $this->em->getRepository('YorkuJuturnaBundle:EcoSystemService')->findBy(array(), array("id" => "ASC")); if ($user && $user != 'anon.') { $mapbookmarks = $this->em->getRepository('Map2uCoreBundle:MapBookmark')->findBy(array("userId" => $user->getId()), array("seq" => "ASC")); } $wellbeingdomains = $this->em->getRepository('YorkuJuturnaBundle:HumanWellBeingDomain')->findBy(array(), array("id" => "ASC")); $parameters = array('context' => $blockContext, 'settings' => $blockContext->getSettings(), 'ecosystems' => $ecosystems, 'wellbeingdomains' => $wellbeingdomains, 'mapbookmarks' => $mapbookmarks, 'block' => $blockContext->getBlock()); if ($blockContext->getSetting('mode') === 'admin') { return $this->renderPrivateResponse($blockContext->getTemplate(), $parameters, $response); } return $this->renderResponse($blockContext->getTemplate(), $parameters, $response); }
/** * {@inheritdoc} */ public function execute(BlockContextInterface $blockContext, Response $response = null) { $criteria = array('mode' => $blockContext->getSetting('mode')); $parameters = array('context' => $blockContext, 'settings' => $blockContext->getSettings(), 'block' => $blockContext->getBlock(), 'pager' => $this->manager->getPager($criteria, 1, $blockContext->getSetting('number')), 'admin_pool' => $this->adminPool); if ($blockContext->getSetting('mode') === 'admin') { return $this->renderPrivateResponse($blockContext->getTemplate(), $parameters, $response); } return $this->renderResponse($blockContext->getTemplate(), $parameters, $response); }
/** * {@inheritdoc} */ public function execute(BlockContextInterface $blockContext, Response $response = null) { $token = $this->securityContext->getToken(); if (!$token) { return new Response(); } $subject = $this->actionManager->findOrCreateComponent($token->getUser(), $token->getUser()->getId()); $entries = $this->timelineManager->getTimeline($subject, array('page' => 1, 'max_per_page' => $blockContext->getSetting('max_per_page'), 'type' => TimelineInterface::TYPE_TIMELINE, 'context' => $blockContext->getSetting('context'), 'filter' => $blockContext->getSetting('filter'), 'group_by_action' => $blockContext->getSetting('group_by_action'), 'paginate' => $blockContext->getSetting('paginate'))); return $this->renderPrivateResponse($blockContext->getTemplate(), array('context' => $blockContext, 'settings' => $blockContext->getSettings(), 'block' => $blockContext->getBlock(), 'entries' => $entries), $response); }
/** * {@inheritdoc} */ public function execute(BlockContextInterface $blockContext, Response $response = null) { $criteria = array('mode' => $blockContext->getSetting('mode')); $indicators = $this->em->getRepository('YorkuJuturnaBundle:Indicator')->findBy(array(), array("id" => "ASC")); $parameters = array('context' => $blockContext, 'settings' => $blockContext->getSettings(), 'indicators' => $indicators, 'block' => $blockContext->getBlock()); if ($blockContext->getSetting('mode') === 'admin') { return $this->renderPrivateResponse($blockContext->getTemplate(), $parameters, $response); } return $this->renderResponse($blockContext->getTemplate(), $parameters, $response); }
/** * {@inheritdoc} */ public function execute(BlockContextInterface $blockContext, Response $response = null) { $admin = $this->pool->getAdminByAdminCode($blockContext->getSetting('code')); $datagrid = $admin->getDatagrid(); $filters = $blockContext->getSetting('filters'); if (!isset($filters['_per_page'])) { $filters['_per_page'] = array('value' => $blockContext->getSetting('limit')); } foreach ($filters as $name => $data) { $datagrid->setValue($name, isset($data['type']) ? $data['type'] : null, $data['value']); } $datagrid->buildPager(); return $this->renderPrivateResponse($blockContext->getTemplate(), array('block' => $blockContext->getBlock(), 'settings' => $blockContext->getSettings(), 'admin_pool' => $this->pool, 'admin' => $admin, 'pager' => $datagrid->getPager(), 'datagrid' => $datagrid), $response); }
/** * {@inheritdoc} */ public function execute(BlockContextInterface $blockContext, Response $response = null) { try { $admin = $this->pool->getAdminByAdminCode($blockContext->getSetting('admin_code')); } catch (ServiceNotFoundException $e) { throw new \RuntimeException('Unable to find the Admin instance', $e->getCode(), $e); } if (!$admin instanceof AdminInterface) { throw new \RuntimeException('The requested service is not an Admin instance'); } if (!$admin->isGranted('LIST')) { throw new AccessDeniedException(); } $pager = $this->searchHandler->search($admin, $blockContext->getSetting('query'), $blockContext->getSetting('page'), $blockContext->getSetting('per_page')); return $this->renderPrivateResponse($admin->getTemplate('search_result_block'), array('block' => $blockContext->getBlock(), 'settings' => $blockContext->getSettings(), 'admin_pool' => $this->pool, 'pager' => $pager, 'admin' => $admin), $response); }
/** * {@inheritdoc} */ public function execute(BlockContextInterface $blockContext, Response $response = null) { $tabs = $blockContext->getSetting('tabs'); foreach ($tabs as $pos => $tab) { $tabs[$pos] = array_merge(array('title' => 'NR Metric', 'reference' => false), $tab); } return $this->renderResponse('EkinoNewRelicBundle:Block:tabs.html.twig', array('tabs' => $tabs, 'settings' => $blockContext->getSettings(), 'block' => $blockContext->getBlock(), 'context' => $blockContext)); }
/** * {@inheritdoc} */ public function execute(BlockContextInterface $blockContext, Response $response = null) { $revisions = array(); foreach ($this->auditReader->findRevisionHistory($blockContext->getSetting('limit'), 0) as $revision) { $revisions[] = array('revision' => $revision, 'entities' => $this->auditReader->findEntitesChangedAtRevision($revision->getRev())); } return $this->renderResponse($blockContext->getTemplate(), array('block' => $blockContext->getBlock(), 'settings' => $blockContext->getSettings(), 'revisions' => $revisions), $response); }
/** * {@inheritdoc} */ public function execute(BlockContextInterface $blockContext, Response $response = null) { $product = $blockContext->getSetting('product'); if (null === $product) { return $this->renderResponse($blockContext->getTemplate(), array('context' => $blockContext, 'settings' => $blockContext->getSettings(), 'block' => $blockContext->getBlock(), 'choices' => array(), 'form' => null), $response); } $fields = $blockContext->getSetting('variations_properties'); $choices = $this->pool->getProvider($product)->getVariationsChoices($product, $fields); $accessor = PropertyAccess::createPropertyAccessor(); $currentValues = array(); foreach ($choices as $field => $values) { $currentValues[$field] = array_search($accessor->getValue($product, $field), $values); } $form = $this->formFactory->createBuilder('sonata_product_variation_choices', $currentValues, array('field_options' => $blockContext->getSetting('form_field_options'), 'product' => $product, 'fields' => $fields))->getForm(); $params = array('context' => $blockContext, 'settings' => $blockContext->getSettings(), 'block' => $blockContext->getBlock(), 'choices' => $choices, 'form' => $form->createView()); return $this->renderResponse($blockContext->getTemplate(), $params, $response); }
/** * {@inheritdoc} */ public function execute(BlockContextInterface $blockContext, Response $response = null) { $tweet = $blockContext->getSetting('tweet'); if (($uriMatched = preg_match(self::TWEET_URL_PATTERN, $tweet)) || preg_match(self::TWEET_ID_PATTERN, $tweet)) { // We matched an URL or an ID, we'll need to ask the API if (class_exists('Guzzle\\Http\\Client') === false) { throw new \RuntimeException('The guzzle http client library is required to call the Twitter API. Make sure to add guzzle/guzzle to your composer.json.'); } // TODO cache API result $client = new \Guzzle\Http\Client(); $client->setConfig(array('curl.options' => array(CURLOPT_CONNECTTIMEOUT_MS => 1000))); try { $request = $client->get($this->buildUri($uriMatched, $blockContext->getSettings())); $apiTweet = json_decode($request->send()->getBody(true), true); $tweet = $apiTweet['html']; } catch (CurlException $e) { // log error } } return $this->renderResponse($blockContext->getTemplate(), array('block' => $blockContext->getBlock(), 'tweet' => $tweet), $response); }
/** * {@inheritdoc} */ public function execute(BlockContextInterface $blockContext, Response $response = null) { if (!$response) { $response = new Response(); } if ($blockContext->getBlock()->getEnabled()) { $qb = $this->dm->createQueryBuilder(); $qb->from()->document('AppBundle\\Document\\TalkBlock', 't')->end()->orderBy()->asc()->field('t.publishEndDate'); if ($maxItems = $blockContext->getSetting('maxItems')) { $qb->setMaxResults($maxItems); } // filter by published $talkBlocks = array(); foreach ($qb->getQuery()->execute() as $document) { if ($this->publishWorkflowChecker->isGranted(PublishWorkflowChecker::VIEW_ANONYMOUS_ATTRIBUTE, $document)) { $talkBlocks[] = $document; } } $response = $this->renderResponse($blockContext->getTemplate(), array('block' => $blockContext->getBlock(), 'talkBlocks' => $talkBlocks), $response); } return $response; }
/** * {@inheritdoc} */ public function execute(BlockContextInterface $blockContext, Response $response = null) { $builder = $this->container->get('form.factory')->createBuilder('form'); $form = $builder->add('categories', 'entity', array('label' => 'Categories:', 'class' => 'Map2uCoreBundle:Category', 'required' => false, 'property' => 'name'))->add('tags', 'entity', array('label' => 'Tags:', 'class' => 'Map2uCoreBundle:Tag', 'required' => false, 'property' => 'name'))->add('spatial_file', 'file', array('mapped' => false, 'label' => 'Select upload spatial files:', 'attr' => array("multiple" => "multiple")))->add('upload_file_list', 'choice', array('mapped' => false, 'label' => 'Selected upload files list:', 'attr' => array('size' => "7", "placeholder" => "upload file list!")))->getForm(); // $form = $this->createForm(); // $userManager = $this->container->get('fos_user.user_manager'); // $user = $userManager->findUserByUsername($this->container->get('security.context') // ->getToken() ->getUser()); // // if ($user && $user != 'anon.') { // $shapefilelist = $this->em->createQuery('SELECT u FROM Map2uCoreBundle:SpatialFile u WHERE u.userId=' . $user->getId() . ' or u.public=true order by u.updatedAt DESC') // ->getResult(); // } // else { // $shapefilelist = $this->em->createQuery('SELECT u FROM Map2uCoreBundle:SpatialFile u WHERE u.public=true order by u.updatedAt DESC') // ->getResult(); // } $parameters = array('context' => $blockContext, 'form' => $form->createView(), 'settings' => $blockContext->getSettings(), 'filetypes' => array('none' => array('type' => 'none', 'name' => 'Do not know yet'), 'pc' => array('type' => 'tradearea', 'name' => 'Trade Area'), 'cs' => array('type' => 'customer', 'name' => 'Customer'), 'poi' => array('type' => 'poi', 'name' => 'POI'), 'map' => array('type' => 'maps', 'name' => 'Maps')), 'block' => $blockContext->getBlock()); if ($blockContext->getSetting('mode') === 'admin') { return $this->renderPrivateResponse($blockContext->getTemplate(), $parameters, $response); } return $this->renderResponse($blockContext->getTemplate(), $parameters, $response); }
/** * {@inheritdoc} */ public function execute(BlockContextInterface $blockContext, Response $response = null) { $settings = $blockContext->getBlock()->getSettings(); $admin = $this->pool->getAdminByAdminCode($blockContext->getSetting('code')); return $this->renderResponse($blockContext->getTemplate(), array('context' => $blockContext, 'block' => $blockContext->getBlock(), 'admin' => $admin, 'settings' => $settings), $response); }
/** * {@inheritdoc} */ public function execute(BlockContextInterface $blockContext, Response $response = null) { $tag = $this->getTag($blockContext->getSetting('tagId'), $blockContext->getSetting('tag')); $tags = $this->tagManager->findBy(array('enabled' => true, 'context' => $blockContext->getSetting('context'))); return $this->renderResponse($blockContext->getTemplate(), array('context' => $blockContext, 'settings' => $blockContext->getSettings(), 'block' => $blockContext->getBlock(), 'tag' => $tag, 'tags' => $tags), $response); }
/** * {@inheritdoc} */ public function execute(BlockContextInterface $blockContext, Response $response = null) { $products = $this->getProductRepository()->findLastActiveProducts($blockContext->getSetting('number')); $params = array('context' => $blockContext, 'settings' => $blockContext->getSettings(), 'block' => $blockContext->getBlock(), 'products' => $products, 'currency' => $this->currencyDetector->getCurrency()); return $this->renderResponse($blockContext->getTemplate(), $params, $response); }
/** * 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) { return $this->renderResponse($blockContext->getTemplate(), array('media' => $blockContext->getSetting('mediaId'), 'block' => $blockContext->getBlock(), 'settings' => $blockContext->getSettings()), $response); }
/** * {@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); }
/** * {@inheritdoc} */ public function execute(BlockContextInterface $blockContext, Response $response = null) { $category = $this->getCategory($blockContext->getSetting('categoryId'), $blockContext->getSetting('category')); $root = $this->categoryManager->getRootCategory($blockContext->getSetting('context')); return $this->renderResponse($blockContext->getTemplate(), array('context' => $blockContext, 'settings' => $blockContext->getSettings(), 'block' => $blockContext->getBlock(), 'category' => $category, 'root' => $root), $response); }
/** * {@inheritdoc} */ public function execute(BlockContextInterface $blockContext, Response $response = null) { return $this->renderResponse($blockContext->getTemplate(), array('block' => $blockContext->getBlock(), 'decorator' => $this->getDecorator($blockContext->getSetting('layout')), 'settings' => $blockContext->getSettings()), $response); }
/** * {@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); }
/** * {@inheritdoc} */ public function execute(BlockContextInterface $blockContext, Response $response = null) { $criteria = array(); return $this->renderResponse($blockContext->getTemplate(), array('context' => $blockContext, 'settings' => $blockContext->getSettings(), 'block' => $blockContext->getBlock(), 'customers' => $this->manager->findBy($criteria, array('createdAt' => 'DESC'), $blockContext->getSetting('number'))), $response); }
/** * {@inheritdoc} */ public function execute(BlockContextInterface $blockContext, Response $response = null) { $collection = $this->getCollection($blockContext->getSetting('collectionId'), $blockContext->getSetting('collection')); $collections = $this->contextManager->findBy(array('enabled' => true, 'context' => $blockContext->getSetting('context'))); return $this->renderResponse($blockContext->getTemplate(), array('context' => $blockContext, 'settings' => $blockContext->getSettings(), 'block' => $blockContext->getBlock(), 'collection' => $collection, 'collections' => $collections), $response); }
/** * {@inheritdoc} */ public function execute(BlockContextInterface $blockContext, Response $response = null) { if (!($product = $this->getProductRepository()->findOneBy(array('id' => $blockContext->getSetting('base_product_id'))))) { return; } $products = $this->getProductFinder()->getCrossSellingSimilarParentProducts($product, $blockContext->getSetting('number')); $params = array('context' => $blockContext, 'settings' => $blockContext->getSettings(), 'block' => $blockContext->getBlock(), 'products' => $products, 'currency' => $this->currencyDetector->getCurrency()); return $this->renderResponse($blockContext->getTemplate(), $params, $response); }