public function setUp() { parent::setUp(); $this->contentQueryExecutor = $this->prophesize('Sulu\\Component\\Content\\Query\\ContentQueryExecutorInterface'); $this->contentQueryBuilder = $this->prophesize('Sulu\\Component\\Content\\Query\\ContentQueryBuilderInterface'); $this->logger = $this->prophesize('Psr\\Log\\LoggerInterface'); $this->property = $this->prophesize('Sulu\\Component\\Content\\Compat\\PropertyInterface'); $this->type = new InternalLinks($this->contentQueryExecutor->reveal(), $this->contentQueryBuilder->reveal(), $this->logger->reveal(), 'some_template.html.twig'); }
/** * {@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; }
private function getContentDataProperty() { $property = $this->getMockForAbstractClass('Sulu\\Component\\Content\\Compat\\PropertyInterface', [], '', true, true, true, ['getValue', 'getParams']); $structure = $this->getMockForAbstractClass('Sulu\\Component\\Content\\Compat\\StructureInterface'); $property->expects($this->exactly(1))->method('getValue')->will($this->returnValue(['dataSource' => '123-123-123'])); $property->expects($this->exactly(1))->method('getParams')->will($this->returnValue([])); $property->expects($this->exactly(3))->method('getStructure')->will($this->returnValue($structure)); $this->contentQuery->expects($this->once())->method('execute')->with($this->equalTo(null), $this->equalTo([null]), $this->equalTo($this->contentQueryBuilder), $this->equalTo(true), $this->equalTo(-1), $this->equalTo(null), $this->equalTo(null))->will($this->returnValue([['uuid' => 1], ['uuid' => 2], ['uuid' => 3], ['uuid' => 4], ['uuid' => 5], ['uuid' => 6]])); $structure->expects($this->any())->method('getUuid')->will($this->returnValue('123-123-123')); return $property; }
/** * 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); }