init() public méthode

initialize query builder.
public init ( array $options )
$options array
Exemple #1
0
 /**
  * {@inheritdoc}
  */
 public function getFilteredNodes(array $filterConfig, $languageCode, $webspaceKey, $preview = false, $api = false, $exclude = [])
 {
     $limit = isset($filterConfig['limitResult']) ? $filterConfig['limitResult'] : null;
     $initParams = ['config' => $filterConfig];
     if ($exclude) {
         $initParams['excluded'] = $exclude;
     }
     $this->queryBuilder->init($initParams);
     $data = $this->queryExecutor->execute($webspaceKey, [$languageCode], $this->queryBuilder, true, -1, $limit);
     if ($api) {
         if (isset($filterConfig['dataSource'])) {
             if ($this->webspaceManager->findWebspaceByKey($filterConfig['dataSource']) !== null) {
                 $node = $this->sessionManager->getContentNode($filterConfig['dataSource']);
             } else {
                 $node = $this->sessionManager->getSession()->getNodeByIdentifier($filterConfig['dataSource']);
             }
         } else {
             $node = $this->sessionManager->getContentNode($webspaceKey);
         }
         $parentNode = $this->getParentNode($node->getIdentifier(), $webspaceKey, $languageCode);
         $result = $this->prepareNode($parentNode, $webspaceKey, $languageCode, 1, false);
         $result['_embedded']['nodes'] = $data;
         $result['total'] = count($result['_embedded']['nodes']);
     } else {
         $result = $data;
     }
     return $result;
 }
Exemple #2
0
 /**
  * {@inheritdoc}
  */
 public function getRootNavigation($webspaceKey, $locale, $depth = 1, $flat = false, $context = null, $loadExcerpt = false)
 {
     if ($this->stopwatch) {
         $this->stopwatch->start('NavigationMapper::getRootNavigation.query');
     }
     $this->queryBuilder->init(['context' => $context, 'excerpt' => $loadExcerpt]);
     $result = $this->contentQuery->execute($webspaceKey, [$locale], $this->queryBuilder, $flat, $depth);
     for ($i = 0; $i < count($result); ++$i) {
         if (!isset($result[$i]['children'])) {
             $result[$i]['children'] = [];
         }
     }
     if ($this->stopwatch) {
         $this->stopwatch->stop('NavigationMapper::getRootNavigation.query');
     }
     return $result;
 }
 /**
  * lazy load data.
  */
 private function loadData($config, $excludeUuids, $limit, $offset)
 {
     if ($this->stopwatch) {
         $this->stopwatch->start('SmartContent:loadData');
     }
     $result = [];
     if (array_key_exists('dataSource', $config) && $config['dataSource'] !== '') {
         $this->contentQueryBuilder->init(['config' => $config, 'properties' => $this->params['properties']->getValue(), 'excluded' => $excludeUuids]);
         $result = $this->contentQueryExecutor->execute($this->webspaceKey, [$this->languageCode], $this->contentQueryBuilder, true, -1, $limit, $offset);
     }
     if ($this->stopwatch) {
         $this->stopwatch->stop('SmartContent:loadData');
     }
     return $result;
 }
Exemple #4
0
 /**
  * Resolves filters.
  */
 private function resolveFilters(array $filters, array $propertyParameter, array $options = [], $limit = null, $page = 1, $pageSize = null)
 {
     if (!array_key_exists('dataSource', $filters) || $filters['dataSource'] === '' || $limit !== null && $limit < 1) {
         return [[], false];
     }
     $properties = array_key_exists('properties', $propertyParameter) ? $propertyParameter['properties']->getValue() : [];
     $this->contentQueryBuilder->init(['config' => $filters, 'properties' => $properties, 'excluded' => $filters['excluded'], 'published' => !$this->showDrafts]);
     $hasNextPage = false;
     if ($pageSize !== null) {
         $result = $this->loadPaginated($options, $limit, $page, $pageSize);
         $hasNextPage = count($result) > $pageSize;
         $items = array_splice($result, 0, $pageSize);
     } else {
         $items = $this->load($options, $limit);
     }
     return [$items, $hasNextPage];
 }
 /**
  * lazy load data.
  */
 private function loadData()
 {
     $result = [];
     if ($this->ids !== null && count($this->ids) > 0) {
         $this->contentQueryBuilder->init(['ids' => $this->ids, 'properties' => isset($this->params['properties']) ? $this->params['properties']->getValue() : []]);
         $pages = $this->contentQueryExecutor->execute($this->webspaceKey, [$this->languageCode], $this->contentQueryBuilder);
         // init vars
         $map = [];
         // map pages
         foreach ($pages as $page) {
             $map[$page['uuid']] = $page;
         }
         foreach ($this->ids as $id) {
             if (isset($map[$id])) {
                 $result[] = $map[$id];
             }
         }
     }
     return $result;
 }