Find content array which given UUIDs.
public findByUuids ( array $uuids, string $locale, Sulu\Component\Content\Repository\Mapping\MappingInterface $mapping, Sulu\Component\Security\Authentication\UserInterface $user = null ) : |
||
$uuids | array | |
$locale | string | |
$mapping | Sulu\Component\Content\Repository\Mapping\MappingInterface | Includes array of property names |
$user | Sulu\Component\Security\Authentication\UserInterface | |
return |
/** * Returns list of custom-url data-arrays. * * @param string $path * @param string $locale * * @return \Iterator */ public function findList($path, $locale) { // TODO pagination $session = $this->sessionManager->getSession(); $queryManager = $session->getWorkspace()->getQueryManager(); $qomFactory = $queryManager->getQOMFactory(); $queryBuilder = new QueryBuilder($qomFactory); $queryBuilder->select('a', 'jcr:uuid', 'uuid'); $queryBuilder->addSelect('a', 'title', 'title'); $queryBuilder->addSelect('a', 'published', 'published'); $queryBuilder->addSelect('a', 'domainParts', 'domainParts'); $queryBuilder->addSelect('a', 'baseDomain', 'baseDomain'); $queryBuilder->addSelect('a', 'sulu:content', 'targetDocument'); $queryBuilder->addSelect('a', 'sulu:created', 'created'); $queryBuilder->addSelect('a', 'sulu:creator', 'creator'); $queryBuilder->addSelect('a', 'sulu:changed', 'changed'); $queryBuilder->addSelect('a', 'sulu:changer', 'changer'); $queryBuilder->from($queryBuilder->qomf()->selector('a', 'nt:unstructured')); $queryBuilder->where($queryBuilder->qomf()->comparison($queryBuilder->qomf()->propertyValue('a', 'jcr:mixinTypes'), QueryObjectModelConstantsInterface::JCR_OPERATOR_EQUAL_TO, $queryBuilder->qomf()->literal('sulu:custom_url'))); $queryBuilder->andWhere($queryBuilder->qomf()->descendantNode('a', $path)); $query = $queryBuilder->getQuery(); $result = $query->execute(); $uuids = array_map(function (Row $item) { return $item->getValue('a.targetDocument'); }, iterator_to_array($result->getRows())); $targets = $this->contentRepository->findByUuids(array_unique($uuids), $locale, MappingBuilder::create()->addProperties(['title'])->getMapping()); return new RowsIterator($result->getRows(), $result->getColumnNames(), $targets, $this->generator, $this->userManager); }
/** * {@inheritdoc} */ public function preload(array $hrefs, $locale, $published = true) { $request = $this->requestStack->getCurrentRequest(); $scheme = 'http'; if ($request) { $scheme = $request->getScheme(); } $contents = $this->contentRepository->findByUuids(array_unique(array_values($hrefs)), $locale, MappingBuilder::create()->setResolveUrl(true)->addProperties(['title', 'published'])->setOnlyPublished($published)->setHydrateGhost(false)->getMapping()); return array_map(function (Content $content) use($locale, $scheme) { return $this->getLinkItem($content, $locale, $scheme); }, $contents); }