@param int $ptID

@return PageTheme
358443
public static function getByID($pThemeID)
    {
        $where = 'pThemeID = ?';
        $args = [$pThemeID];
        $pt = static::populateThemeQuery($where, $args);

        return $pt;
    }
1154975
public static function style($styleID)
    {
        if (!in_array($styleID, static::getKnownStyles())) {
            throw new Exception("Unknown style ID $styleID");
        }

        $style = new Style($styleID);

        return $style;
    }
579270
public function getCollectionPages($collectionId)
    {
        $pageMapper = ($this->container->dataMapper)('PageMapper');

        // Page Collection
        $data = $pageMapper->findCollectionPagesById($collectionId);

        return $data;
    }
515792
public function openOrchestraCss($themeId)
    {
        $tags = '';

        if (isset($this->themes[$themeId]) && isset($this->themes[$themeId]['stylesheets'])) {
            $stylesheets = $this->themes[$themeId]['stylesheets'];
            foreach ($stylesheets as $stylesheet) {
                $tags .= $this->getHtmlTag($stylesheet, self::FILETYPE_CSS);
            }
        }

        return $tags;
    }
359915
public function findOneByPageIdAndByLanguageId($pageId, $languageId)
    {
        $documentCollection = $this->findByPageIdAndByLanguageId($pageId, $languageId);
        return reset($documentCollection);
    }
1191274
public static function initFrontend( $pageid )
	{
		if( !is_object( $GLOBALS['TT'] ) )
		{
			$GLOBALS['TT'] = GeneralUtility::makeInstance( 'TYPO3\CMS\Core\TimeTracker\TimeTracker' );
			$GLOBALS['TT']->start();
		}

		$page = GeneralUtility::makeInstance( 'TYPO3\CMS\Frontend\Page\PageRepository' );
		$page->init( true );

		$name = 'TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController';
		$GLOBALS['TSFE'] = GeneralUtility::makeInstance( $name,  $GLOBALS['TYPO3_CONF_VARS'], $pageid, 0 );
		$GLOBALS['TSFE']->connectToDB();
		$GLOBALS['TSFE']->initFEuser();
		$GLOBALS['TSFE']->no_cache = true;
		$GLOBALS['TSFE']->sys_page = $page;
		$GLOBALS['TSFE']->rootLine = $page->getRootLine( $pageid );
		$GLOBALS['TSFE']->determineId();
		$GLOBALS['TSFE']->initTemplate();
		$GLOBALS['TSFE']->getConfigArray();

		$rootline = BackendUtility::BEgetRootLine( $pageid );
		$host = BackendUtility::firstDomainRecord( $rootline );

		if( $host == null && ( $host = getenv( 'SCHEDULER_HTTP_HOST' ) ) == null ) {
			throw new \RuntimeException( 'No domain record in root page or SCHEDULER_HTTP_HOST env variable found' );
		}

		$_SERVER['HTTP_HOST'] = $host;
		GeneralUtility::flushInternalRuntimeCaches();
	}
71382
protected function getSubPageIds($pageId)
    {
        /** @var $queryGenerator \TYPO3\CMS\Core\Database\QueryGenerator */
        $queryGenerator = GeneralUtility::makeInstance(QueryGenerator::class);

        // here we retrieve only the subpages of this page because the permission clause is not evaluated
        // on the root node.
        $permissionClause = ' 1 ' . BackendUtility::BEenableFields('pages');
        $treePageIdList = $queryGenerator->getTreeList($pageId, 20, 0, $permissionClause);
        $treePageIds = array_map('intval', explode(',', $treePageIdList));

            // the first one can be ignored because this is the page itself
        array_shift($treePageIds);

        return $treePageIds;
    }
995238
protected function getPageEditLink($pageId, $documentSetId)
    {
        return Controller::join_links(
            CMSPageEditController::singleton()->getEditForm($pageId)->FormAction(),
            'field/DocumentSets/item',
            (int) $documentSetId
        );
    }
163320
public function editAction($pageId)
    {
        $options = array(
            'pageId' => $pageId,
            'pageMetas' => $this->getPageMetas($pageId)
        );
        $page = $this->getPage($pageId);
        return $this->createPage(
                $page,
                $options,
                $models = $this->container->getParameter('fulgurio_light_cms.models')
        );
    }
34453
public function getPageLayout($pageId, $pageThemeId = null)
    {
        $sections = $templateSections = [];
        $error    = '';
        $details  = [];

        /** @var $pageModel \PageBuilder\Model\PageModel */
        $pageModel = $this->getServiceLocator()->get('pagebuilder\model\page');

        /** @var $themeModel \PageBuilder\Model\BaseModel */
        $themeModel = $this->getServiceLocator()->get('pagebuilder\model\theme');

        /** @var $templateModel \PageBuilder\Model\BaseModel */
        $templateModel = $this->getServiceLocator()->get('pagebuilder\model\template');

        /** @var $page \PageBuilder\Entity\Page */
        if ($page = $pageModel->getRepository()->find($pageId)) {

            $details = [
                'id'          => $page->getId(),
                'title'       => $page->getTitle(),
                'description' => $page->getDescription(),
                'template'    => $page->getTemplate() ? $page->getTemplate()->getTitle() : '',
                'layout'      => '',
                'pageTheme'   => '',
                'themeId'     => '',
                'layoutType'  => 'Custom Layout',
                'parent'      => $page->getParent() ? $page->getParent()->getTitle() : '',

            ];
        }
        $themeId = $pageTheme = null;
        if ($pageThemeId) {
            /** @var $pageThemeModel \PageBuilder\Model\BaseModel */
            $pageThemeModel = $this->getServiceLocator()->get('pagebuilder\model\pageTheme');
            $pageTheme      = $pageThemeModel->findObject($pageThemeId);
            $themeId        = $pageTheme->getId();
        }

        if ($themeId and $pageTheme) {
            $details['themeId'] = $themeId;

            $details['layout']    = $pageTheme->getLayout();
            $details['pageTheme'] = $pageTheme->getId();

            /** @var $temp \PageBuilder\Entity\Template */
            if ($temp = $page->getTemplate()) {
                $sections = $temp->getTemplateSections()->toArray();
            } elseif ($temp = $page->getParent()->getTemplate()) {
                $sections = $temp->getTemplateSections()->toArray();
            }
        }
        /** @var $section \PageBuilder\Entity\Join\TemplateSection */
        foreach ($sections as $section) {
            $slug                    = $section->getSectionId()->getSlug();
            $templateSections[$slug] = [
                'title'  => $section->getSectionId()->getTitle(),
                'status' => $section->getIsActive() ? 1 : 0,
                'class'  => $section->getIsActive() ? '' : 'in-active',
            ];
        }

        if ($themeData = $themeModel->getRepository()->findAll()) {
            /** @var $theme \PageBuilder\Entity\Theme */
            foreach ($themeData as $theme) {
                $details['themes'][$theme->getId()] = $theme->toArray();
            }
        } else {
            $details['themes'] = [];
        }

        /** @var $templateModel \PageBuilder\Model\TemplateModel */
        $templates  = $templateModel->listTemplates();
        $components = $this->getServiceLocator()->get('pagebuilder\model\component')->listItemsByTitle();

        /** @var $widgetUtil \PageBuilder\Util\Widget */
        $widgetUtil = $this->getServiceLocator()->get('util\widget');

        $widgetList = $widgetUtil->getWidgetList();
        $urlHelper  = $this->getServiceLocator()->get('ViewHelperManager')->get('url');

        $return = [
            'error'     => $error,
            'page'      => $details,
            'editUrl'   => $pageThemeId
                ? $urlHelper('builder\theme', ['id' => $pageThemeId])
                : $urlHelper(
                    'builder', ['id' => $pageId]
                ),
            'sections'  => $templateSections,
            'title'     => 'Layout Manager - ' . ($page ? $page->getTitle() : ''),
            'widgets'   => [
                'title' => 'Widgets',
                'items' => $widgetUtil->getRegistry(),
                'total' => count($widgetUtil->getRegistry()),
                'list'  => $widgetList,
                'id'    => PageBuilder::LAYOUT_WIDGET,
            ],
            'assets'    => [
                PageBuilder::LAYOUT_USER_DEFINED => [
                    'title' => 'User Defined',
                    'items' => $components,
                ],
            ],
            'templates' => [
                'title' => 'Templates',
                'items' => $templates,
            ],
            'tags'      => $this->_getTaglist(),
        ];

        return $return;
    }
1063483
public function getPageTypeComposerOutputControlObject(Template $pt)
    {
        $app = Application::getFacadeApplication();
        $db = $app->make('database')->connection();
        $ptComposerOutputControlID = $db->fetchColumn(
            'select ptComposerOutputControlID from PageTypeComposerOutputControls where ptComposerFormLayoutSetControlID = ? and pTemplateID = ?',
            [$this->ptComposerFormLayoutSetControlID, $pt->getPageTemplateID()]
        );
        if ($ptComposerOutputControlID) {
            return PageTypeComposerOutputControl::getByID($ptComposerOutputControlID);
        }
    }
776645
public function getPageThemeById($id, $mode = AbstractQuery::HYDRATE_OBJECT)
    {
        $qb = $this->getEntityManager()->createQueryBuilder();
        /** @var $query \Doctrine\ORM\Query */

        $query = $qb->select('e, m')
            ->from($this->getEntity(), 'e')
            ->innerJoin('e.pageId', 'm')
            ->where('e.id = :id')
            ->setMaxResults(1)
            ->setParameter('id', $id)
            ->getQuery();

        return $query->getOneOrNullResult($mode);
    }
975132
public function init($pageId, array $typoScriptSetup = [])
    {
        $this->setLanguageService($GLOBALS['LANG']);
        $pageId = (strpos($pageId, 'NEW') === 0) ? 0 : (int)$pageId;
        if ((int)$pageId < 0) {
            $pageId = Helper::getInstance()->getPidFromUid($pageId);
        }
        $this->realPid = $pageId;
        $this->loadLayoutSetup($pageId);
        foreach ($this->layoutSetup as $key => $setup) {
            $columns = $this->getLayoutColumns($key);
            if ($columns['allowed'] || $columns['disallowed'] || $columns['maxitems']) {
                $this->layoutSetup[$key]['columns'] = $columns;
                unset($this->layoutSetup[$key]['columns']['allowed']);
                $this->layoutSetup[$key]['allowed'] = $columns['allowed'] ?: [];
                $this->layoutSetup[$key]['disallowed'] = $columns['disallowed'] ?: [];
                $this->layoutSetup[$key]['maxitems'] = $columns['maxitems'] ?: [];
            }
        }
        $this->setTypoScriptSetup($typoScriptSetup);
        return $this;
    }
1054391
public function getActiveSiteTheme($siteId)
    {
        $qb = $this->getEntityManager()->createQueryBuilder();
        /** @var $query \Doctrine\ORM\Query */

        $query = $qb->select('e, t')
            ->from($this->_entity, 'e')
            ->innerJoin('e.themeId', 't')
            ->where('e.siteId = :id')
            ->andWhere('e.isActive = 1')
            ->setMaxResults(1)
            ->setParameter('id', $siteId)
            ->getQuery();

        /** @var $result \PageBuilder\Entity\Join\SiteTheme */
        $result = $query->getOneOrNullResult(AbstractQuery::HYDRATE_OBJECT);
        if ($result) {
            return $result->getThemeId();
        } else {
            return $result;
        }
    }
591062
public function createPager($contextId = null)
    {
        $pager = new Pager($this);
        $pager->setFor($contextId);

        return $this->pagers[$this->makeParameterId($contextId)] = $pager;
    }
1023950
public function listAction($pageId = NULL)
    {
        $pages = $this->getDoctrine()->getRepository('FulgurioLightCMSBundle:Page')->findBy(array('page_type' => 'page'), array('position' => 'ASC'));
        $childrenPages = array();
        foreach ($pages as $page)
        {
            if ($page->isRoot())
            {
                $pageRoot = $page;
            }
            if (!is_null($pageId) && $page->getId() == $pageId)
            {
                $currentPage = $page;
            }
            if (!isset($childrenPages[$page->getParentId()]))
            {
                $childrenPages[$page->getParentId()] = array();
            }
            $childrenPages[$page->getParentId()][] = $page;
        }
        $data = array(
            'pageRoot' => array($pageRoot),
            'childrenPages' => $childrenPages
        );
        if (!is_null($pageId))
        {
            if (!isset($currentPage))
            {
                throw new NotFoundHttpException($this->get('translator')->trans('fulgurio.lightcms.page_not_found', array(), 'admin'));
            }
            $models = $this->container->getParameter('fulgurio_light_cms.models');
            $templateName = isset($models[$currentPage->getModel()]['back']['view']) ? $models[$currentPage->getModel()]['back']['view'] : 'FulgurioLightCMSBundle:models:standardAdminView.html.twig';
            $data['selectedPage'] = $currentPage;
        }
        else
        {
            $templateName = 'FulgurioLightCMSBundle:AdminPage:list.html.twig';
        }
        return $this->render($templateName, $data);
    }
1180886
public function getBackendLayoutForPage(int $uid) {
    $rootLine = $this->pageRepository->getRootLine($uid);

    if ($rootLine) {
      $index = -1;

      foreach($rootLine as $page) {
        $index++;

        $backendLayout             = $page['backend_layout'];
        $hasBackendLayout          = false;
        $backendLayoutNextLevel    = $page['backend_layout_next_level'];
        $hasBackendLayoutNextLevel = false;

        if (!empty($backendLayout)) {
          $backendLayout = str_replace(self::BACKEND_LAYOUT_PREFIX, '', $backendLayout);
        }

        if (!empty($backendLayout) && $backendLayout != '-1') {
          $hasBackendLayout = true;
        }

        if (!empty($backendLayoutNextLevel)) {
          $backendLayoutNextLevel = str_replace(self::BACKEND_LAYOUT_PREFIX, '', $backendLayoutNextLevel);
        }

        if (!empty($backendLayoutNextLevel) && $backendLayoutNextLevel != '-1') {
          $hasBackendLayoutNextLevel = true;
        }

        if ($index == 0 && $hasBackendLayout) {
          return $backendLayout;
        } elseif ($index > 0 && $hasBackendLayoutNextLevel) {
          return $backendLayoutNextLevel;
        }
      }
    }

    return null;
  }