Executes a query and returns loaded content as array.
public execute ( string $webspaceKey, string[] $locales, Sulu\Component\Content\Query\ContentQueryBuilderInterface $contentQueryBuilder, boolean $flat = true, integer $depth, integer $limit = null, integer $offset = null, boolean $moveUp = false ) : array | ||
$webspaceKey | string | |
$locales | string[] | |
$contentQueryBuilder | Sulu\Component\Content\Query\ContentQueryBuilderInterface | |
$flat | boolean | |
$depth | integer | |
$limit | integer | |
$offset | integer | |
$moveUp | boolean | |
return | array |
/** * {@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; }
/** * {@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; }
/** * 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; }
/** * @param string $webspaceKey * @param array $locales * @param bool $flat * * @return array */ private function generateByLocals($webspaceKey, $locales, $flat = false) { return $this->contentQuery->execute($webspaceKey, $locales, $this->contentQueryBuilder, $flat, -1, null, null, true); }
/** * Load data. * * @param array $options * @param int $limit * * @return array */ private function load(array $options, $limit) { return $this->contentQueryExecutor->execute($options['webspaceKey'], [$options['locale']], $this->contentQueryBuilder, true, -1, $limit); }