Sulu\Component\Content\Repository\ContentRepositoryInterface::findByUuids PHP Method

findByUuids() public method

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 ) : Content[]
$uuids array
$locale string
$mapping Sulu\Component\Content\Repository\Mapping\MappingInterface Includes array of property names
$user Sulu\Component\Security\Authentication\UserInterface
return Content[]
    public function findByUuids(array $uuids, $locale, MappingInterface $mapping, UserInterface $user = null);

Usage Example

示例#1
0
 /**
  * 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);
 }
All Usage Examples Of Sulu\Component\Content\Repository\ContentRepositoryInterface::findByUuids