Frontend\Core\Engine\Page::getPageContent PHP Method

getPageContent() protected method

Get page content
protected getPageContent ( $pageId ) : array
$pageId
return array
    protected function getPageContent($pageId)
    {
        // load revision
        if ($this->URL->getParameter('page_revision', 'int') != 0) {
            // get data
            $record = Model::getPageRevision($this->URL->getParameter('page_revision', 'int'));
            // add no-index to meta-custom, so the draft won't get accidentally indexed
            $this->header->addMetaData(array('name' => 'robots', 'content' => 'noindex, nofollow'), true);
        } else {
            // get page record
            $record = (array) Model::getPage($pageId);
        }
        if (empty($record)) {
            return array();
        }
        // init var
        $redirect = true;
        // loop blocks, if all are empty we should redirect to the first child
        foreach ($record['positions'] as $blocks) {
            // loop blocks in position
            foreach ($blocks as $block) {
                // HTML provided?
                if ($block['html'] != '') {
                    $redirect = false;
                }
                // an decent extra provided?
                if ($block['extra_type'] == 'block') {
                    $redirect = false;
                }
                // a widget provided
                if ($block['extra_type'] == 'widget') {
                    $redirect = false;
                }
            }
        }
        // should we redirect?
        if ($redirect) {
            // get first child
            $firstChildId = Navigation::getFirstChildId($record['id']);
            // validate the child
            if ($firstChildId !== false) {
                // build URL
                $url = Navigation::getURL($firstChildId);
                // redirect
                throw new RedirectException('Redirect', new RedirectResponse($url, 301));
            }
        }
        return $record;
    }