Exemple #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);
 }
Exemple #2
0
 /**
  * {@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);
 }
Exemple #3
0
 /**
  * {@inheritdoc}
  */
 public function build($page, $portalKey, $locale)
 {
     $pages = $this->contentRepository->findAllByPortal($locale, $portalKey, MappingBuilder::create()->addProperties(['changed', 'seo-hideInSitemap'])->setResolveUrl(true)->setHydrateGhost(false)->getMapping());
     $result = [];
     foreach ($pages as $contentPage) {
         if (!$contentPage->getUrl() || true === $contentPage['seo-hideInSitemap']) {
             continue;
         }
         $changed = $contentPage['changed'];
         if (is_string($changed)) {
             $changed = new \DateTime($changed);
         }
         $result[] = $sitemapUrl = new SitemapUrl($contentPage->getUrl(), $changed);
         foreach ($contentPage->getUrls() as $urlLocale => $href) {
             $sitemapUrl->addAlternateLink(new SitemapAlternateLink($href, $urlLocale));
         }
     }
     return $result;
 }