findAllByPortal() public method

Find all pages and returns an array of content.
public findAllByPortal ( string $locale, string $portalKey, Sulu\Component\Content\Repository\Mapping\MappingInterface $mapping, Sulu\Component\Security\Authentication\UserInterface $user = null ) : Content[]
$locale string
$portalKey string
$mapping Sulu\Component\Content\Repository\Mapping\MappingInterface
$user Sulu\Component\Security\Authentication\UserInterface
return Content[]
示例#1
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;
 }