Get the list of draft pages in a specific site.

@param \Concrete\Core\Entity\Site\Site $site

@return \Concrete\Core\Page\Page[]
513753
public static function getDrafts(Site $site)
    {
        $db = Database::connection();
        $nc = self::getDraftsParentPage($site);
        $r = $db->executeQuery('select Pages.cID from Pages inner join Collections c on Pages.cID = c.cID where cParentID = ? order by cDateAdded desc', [$nc->getCollectionID()]);
        $pages = [];
        while ($row = $r->FetchRow()) {
            $entry = self::getByID($row['cID']);
            if (is_object($entry)) {
                $pages[] = $entry;
            }
        }

        return $pages;
    }
47737
protected function getInitializedIndexService(Site $site)
    {
        $indexService = GeneralUtility::makeInstance(IndexService::class, /** @scrutinizer ignore-type */ $site);
        $indexService->setContextTask($this);
        return $indexService;
    }
558565
private function ensureSiteMenus(Site $site)
    {
        $ret = [];

        if ($this->treeManager && $this->allowedMenus) {
            $storage = $this->treeManager->getMenuStorage();

            foreach ($this->allowedMenus as $prefix => $title) {

                $name = $prefix.'-'.$site->getId();

                if (!$storage->exists($name)) {
                    $ret[$name] = $storage->create($name, ['title' => $this->t($title), 'site_id' => $site->getId()]);
                }
            }
        }

        return $ret;
    }
687767
public function get(
        $root = null,
        $siteId = null,
        $pages = null,
        $pageType = null,
        $pageName = null
    ) {
        if (empty($root)) {
            $root = self::RESOURCE_SITES;
        }

        if (empty($siteId)) {
            return $root;
        }

        if (empty($pages)) {
            return $root . '.' . $siteId;
        }

        if (empty($pageType) || empty($pageName)) {
            return $root . '.' . $siteId . '.' . $pages;
        }

        return $root . '.' . $siteId . '.' . $pages . '.' . $pageType . '.' . $pageName;
    }
611531
public function getSettingList(Site $site)
    {
        $settingList = [];
        $items       = $this->getSettingBySiteId($site->getId());
        /** @var $setting \PageBuilder\Entity\Setting */
        foreach ($items as $setting) {
            $code               = $setting->getSettingKey()->getCode();
            $value              = $setting->getSettingValue() ?: $setting->getSettingKey()->getDefaultValue();
            $settingList[$code] = $value;
        }

        $locale                = $site->getLocale() ?: 'en_GB';
        $settingList           = array_merge($settingList, \Locale::parseLocale($locale));
        $settingList['locale'] = $locale;

        return $settingList;
    }
798129
public function getRoot(Site $site)
    {
        try {
            $query = $this->createQueryBuilder('s')
                    ->andWhere('s._site = :site')
                    ->andWhere('s._parent is null')
                    ->setMaxResults(1)
                    ->setParameters([
                        'site' => $site,
                    ]);

            return $query->getQuery()->getSingleResult();
        } catch (NoResultException $e) {
            return;
        } catch (\Exception $e) {
            return;
        }
    }
825666
public function getFilteredPages()
    {
        $pages = Versioned::get_by_stage(SiteTree::class, 'Stage');
        $pages = $this->applyDefaultFilters($pages);
        $pages = $pages->filterByCallback(function (SiteTree $page) {
            // If page exists on stage but not on live
            return $page->isOnDraftOnly();
        });
        return $pages;
    }
832906
public function listPagesBuilds(): array
    {
        return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/pages/builds',
            $this->getRepositories()->getOwner(), $this->getRepositories()->getRepo()));
    }
1063773
public function listFilesOfSite($site, array $filter = null, array $sortOrder = null, array $limit = null) {
		$timeStamp = microtime(true);
		$sModel = $this->kernel->getContainer()->get('sitemanagement.model');
		$response = $sModel->getSite($site);
		if($response->error->exist){
			return $response;
		}
		$site = $response->result->set;
		$filter[] = array(
			'glue' => ' and',
			'condition' => array(
				'column' => $this->entity['f']['alias'] . '.site',
				'comparison' => '=',
				'value' => $site->getId())
		);
		$response = $this->listFiles($filter, $sortOrder, $limit);

		$response->stats->execution->start = $timeStamp;
		$response->stats->execution->end = microtime(true);

		return $response;
    }
1130663
protected function prepareDefaultValues(Site $site)
    {
        $defaults = $this->getDefaultSiteValues();

        foreach ($defaults as $key => $value) {
            $getMethod = 'get' . ucfirst($key);
            $setMethod = 'set' . ucfirst($key);

            $currentValue = $site->$getMethod();

            if (empty($currentValue)) {
                $site->$setMethod($value);
            }
        }

        return $site;
    }
658581
public function getAvailableSites()
    {
        $sites = array();
        $token = $this->tokenStorage->getToken();
        if ($token instanceof TokenInterface) {
            if ($this->authorizationChecker->isGranted(ContributionRoleInterface::PLATFORM_ADMIN)) {
                return $this->siteRepository->findByDeleted(false);
            }

            if (($user = $token->getUser()) instanceof GroupableInterface) {
                foreach ($user->getGroups() as $group) {
                    /** @var SiteInterface $site */
                    $site = $group->getSite();
                    if (null !== $site && !$group->isDeleted() && !$site->isDeleted()) {
                        $sites[$site->getId()] = $site;
                    }
                }
            }
        }

        return $sites;
    }
128826
protected function getDomainListOfAllSites()
    {
        $sites = $this->getAvailableSites();
        $domains = [];
        foreach ($sites as $site) {
            $domains[] = $site->getDomain();
        }

        $allowedSites = implode(',', $domains);
        return $allowedSites;
    }
383560
public static function staticPages()
    {
        if (!getConfig('sitemap.static_pages')) {
            return [];
        }

        return array_map(function (Entity $page) {
            return self::parse(['_name' => 'page', $page->slug], ['lastmod' => $page->modified]);
        }, StaticPage::all());
    }
1182732
protected function createPagePlugins(
        Site $site,
        string $createdByUserId,
        string $createdReason = Tracking::UNKNOWN_REASON,
        $pagesData = [],
        $doFlush = true
    ) {
        $entityManager = $this->getEntityManager();

        /** @var \Rcm\Repository\Page $pageRepo */
        $pageRepo = $entityManager->getRepository(
            \Rcm\Entity\Page::class
        );

        /** @var \Rcm\Repository\PluginInstance $pluginInstanceRepo */
        $pluginInstanceRepo = $entityManager->getRepository(
            \Rcm\Entity\PluginInstance::class
        );

        /** @var \Rcm\Repository\PluginWrapper $pluginWrapperRepo */
        $pluginWrapperRepo = $entityManager->getRepository(
            \Rcm\Entity\PluginWrapper::class
        );

        $pages = [];
        $pageRevisions = [];

        foreach ($pagesData as $pageName => $pageData) {
            if (empty($pageData['plugins'])) {
                continue;
            }

            $page = $pageRepo->getPageByName($site, $pageData['name']);

            if (empty($page)) {
                continue;
            }

            $page->setModifiedByUserId(
                $createdByUserId,
                $createdReason
            );

            $pages[] = $page;

            $pageRevision = $page->getPublishedRevision();

            if (empty($pageRevision)) {
                throw new \Exception(
                    "Could not find published revision for page {$page->getPageId()}"
                );
            }

            foreach ($pageData['plugins'] as $pluginData) {
                $pluginInstance = $pluginInstanceRepo->createPluginInstance(
                    $pluginData,
                    $site,
                    $createdByUserId,
                    $createdReason,
                    null,
                    $doFlush
                );

                $pluginData['pluginInstanceId'] = $pluginInstance->getInstanceId();

                $wrapper = $pluginWrapperRepo->savePluginWrapper(
                    $pluginData,
                    $site,
                    $createdByUserId,
                    $createdReason,
                    null,
                    $doFlush
                );

                $pageRevision->addPluginWrapper($wrapper);

                $pageRevision->setModifiedByUserId(
                    $createdByUserId,
                    $createdReason
                );

                $entityManager->persist($pageRevision);

                $pageRevisions[] = $pageRevision;
            }
        }

        if ($doFlush) {
            $entityManager->flush($pages);
            $entityManager->flush($pageRevisions);
        }
    }
212487
public function getHybridPages(SiteInterface $site)
    {
        return $this->getEntityManager()->createQueryBuilder()
            ->select('p')
            ->from($this->class, 'p')
            ->where('p.routeName <> :routeName and p.site = :site')
            ->setParameters([
                'routeName' => PageInterface::PAGE_ROUTE_CMS_NAME,
                'site' => $site->getId(),
            ])
            ->getQuery()
            ->execute();
    }
235099
public function createForSite(SiteInterface $site)
    {
        $listRedirection = $this->redirectionRepository->findBySiteId($site->getSiteId());
        $siteLanguages = $site->getLanguages();
        $routes = array();

        foreach ($siteLanguages as $language) {
            $nodes = $this->nodeRepository->findPublishedByLanguageAndSiteId($language, $site->getSiteId());
            $routePattern = $this->nodeRepository->findAllRoutePattern($language, $site->getSiteId());
            $routePattern = $this->computeRoutePattern($routePattern);
            foreach ($nodes as $node) {
                $routes = array_merge($this->generateRoutesForNode($node, $site, $routePattern), $routes);
            }
        }

        foreach ($listRedirection as $redirection) {
            $routes = array_merge($this->generateRoutesForRedirection($redirection, $site), $routes);
        }

        return $routes;
    }
912407
public function generatePageList()
    {
        $this->now = new DateTime();
        $siteTreeIDList = array_merge([0], $this->getSiteTreesIDList());
        $connection = $this->getConnection();
        $rs = $connection->executeQuery('select cID from Pages where siteTreeID is null or siteTreeID in (' . implode(', ', $siteTreeIDList) . ')');
        while (($cID = $rs->fetchColumn()) !== false) {
            $page = Page::getByID($cID, 'ACTIVE');
            if ($page && $this->canIncludePageInSitemap($page)) {
                yield $page;
            }
        }
    }