Bundle/SitemapBundle/Domain/Export/SitemapExportHandler.php
public function handle($locale)
    {
        $homepage = $this->entityManager->getRepository(Page::class)
            ->findOneByHomepage($locale);

        /** @var ViewReference $tree */
        $tree = $this->viewReferenceRepo->getOneReferenceByParameters(
            ['viewId' => $homepage->getId(), 'locale' => $locale],
            true,
            true
        );

        $ids = [$tree->getViewId()];

        $getChildrenIds = function (ViewReference $tree) use (&$getChildrenIds, $ids) {
            foreach ($tree->getChildren() as $child) {
                if (null !== $child->getViewId()) {
                    $ids[] = $child->getViewId();
                    $ids = array_merge($ids, $getChildrenIds($child));
                }
            }

            return array_unique($ids);
        };
        $ids = $getChildrenIds($tree);
        $pages = $this->entityManager->getRepository(BasePage::class)
            ->getAll(true)
            ->joinSeo()
            ->joinSeoTranslations($locale)
            ->filterByIds($ids)
            ->run();

        /** @var Page $page */
        foreach ($pages as $page) {
            $page->setCurrentLocale($locale);
            $this->entityManager->refresh($page);
            $page->translate($locale);
        }
        $items = array_merge($pages, $this->getBusinessPages($tree));
        usort(
            $items,
            function ($a, $b) {
                return strcmp($a->getUrl(), $b->getUrl());
            }
        );

        return $items;
    }
public function handle($locale)
    {
        $homepage = $this->entityManager->getRepository(Page::class)
            ->findOneByHomepage($locale);

        /** @var ViewReference $tree */
        $tree = $this->viewReferenceRepo->getOneReferenceByParameters(
            ['viewId' => $homepage->getId(), 'locale' => $locale],
            true,
            true
        );

        $ids = [$tree->getViewId()];

        $getChildrenIds = function (ViewReference $tree) use (&$getChildrenIds, $ids) {
            foreach ($tree->getChildren() as $child) {
                if (null !== $child->getViewId()) {
                    $ids[] = $child->getViewId();
                    $ids = array_merge($ids, $getChildrenIds($child));
                }
            }

            return array_unique($ids);
        };
        $ids = $getChildrenIds($tree);
        $pages = $this->entityManager->getRepository(BasePage::class)
            ->getAll(true)
            ->joinSeo()
            ->joinSeoTranslations($locale)
            ->filterByIds($ids)
            ->run();

        /** @var Page $page */
        foreach ($pages as $page) {
            $page->setCurrentLocale($locale);
            $this->entityManager->refresh($page);
            $page->translate($locale);
        }
        $items = array_merge($pages, $this->getBusinessPages($tree));
        usort(
            $items,
            function ($a, $b) {
                return strcmp($a->getUrl(), $b->getUrl());
            }
        );

        return $items;
    }
public function handle ( $ locale ) { $ homepage = $ this -> entityManager -> getRepository ( Page :: class ) -> findOneByHomepage ( $ locale ) ; /** @var ViewReference $tree */ $ tree = $ this -> viewReferenceRepo -> getOneReferenceByParameters ( [ 'viewId' => $ homepage -> getId ( ) , 'locale' => $ locale ] , true , true ) ; $ ids = [ $ tree -> getViewId ( ) ] ; $ getChildrenIds = function ( ViewReference $ tree ) use ( & $ getChildrenIds , $ ids ) { foreach ( $ tree -> getChildren ( ) as $ child ) { if ( null !== $ child -> getViewId ( ) ) { $ ids [ ] = $ child -> getViewId ( ) ; $ ids = array_merge ( $ ids , $ getChildrenIds ( $ child ) ) ; } } return array_unique ( $ ids ) ; } ; $ ids = $ getChildrenIds ( $ tree ) ; $ pages = $ this -> entityManager -> getRepository ( BasePage :: class ) -> getAll ( true ) -> joinSeo ( ) -> joinSeoTranslations ( $ locale ) -> filterByIds ( $ ids ) -> run ( ) ; /** @var Page $page */ foreach ( $ pages as $ page ) { $ page -> setCurrentLocale ( $ locale ) ; $ this -> entityManager -> refresh ( $ page ) ; $ page -> translate ( $ locale ) ; } $ items = array_merge ( $ pages , $ this -> getBusinessPages ( $ tree ) ) ; usort ( $ items , function ( $ a , $ b ) { return strcmp ( $ a -> getUrl ( ) , $ b -> getUrl ( ) ) ; } ) ; return $ items ; }
Get the whole list of published pages for a given locale.

#1 Parse recursively and extract every persisted pages ids
#2 load these pages with seo (if exists)
#3 parse recursively and extract every VirtualBusinessPages references
#4 prepare VirtualBusinessPages.

@param $locale

@return array
Get the whole list of published pages for a given locale .