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

load() public method

Loads the actual components on the page
public load ( )
    public function load()
    {
        // set tracking cookie
        Model::getVisitorId();
        // create header instance
        $this->header = new Header($this->getKernel());
        // get page content from pageId of the requested URL
        $this->record = $this->getPageContent(Navigation::getPageId(implode('/', $this->URL->getPages())));
        if (empty($this->record)) {
            $this->record = Model::getPage(404);
        }
        // authentication
        if (BackendModel::isModuleInstalled('Profiles') && isset($this->record['data']['auth_required'])) {
            $data = $this->record['data'];
            // is auth required and is profile logged in
            if ($data['auth_required']) {
                if (!FrontendAuthenticationModel::isLoggedIn()) {
                    // redirect to login page
                    $queryString = $this->URL->getQueryString();
                    throw new RedirectException('Redirect', new RedirectResponse(Navigation::getURLForBlock('Profiles', 'Login') . '?queryString=' . $queryString));
                }
                // specific groups for auth?
                if (!empty($data['auth_groups'])) {
                    $inGroup = false;
                    foreach ($data['auth_groups'] as $group) {
                        if (FrontendAuthenticationModel::getProfile()->isInGroup($group)) {
                            $inGroup = true;
                        }
                    }
                    if (!$inGroup) {
                        $this->record = Model::getPage(404);
                    }
                }
            }
        }
        // we need to set the correct id
        $this->pageId = (int) $this->record['id'];
        // set headers if this is a 404 page
        if ($this->pageId == 404) {
            $this->statusCode = 404;
            if (extension_loaded('newrelic')) {
                newrelic_name_transaction('404');
            }
        }
        // create breadcrumb instance
        $this->breadcrumb = new Breadcrumb($this->getKernel());
        // new footer instance
        $this->footer = new Footer($this->getKernel());
        // process page
        $this->processPage();
        // execute all extras linked to the page
        $this->processExtras();
        // store statistics
        $this->storeStatistics();
        // trigger event
        Model::triggerEvent('Core', 'after_page_processed', array('id' => $this->getId(), 'record' => $this->getRecord(), 'statusCode' => $this->getStatusCode(), 'sessionId' => \SpoonSession::getSessionId(), 'visitorId' => Model::getVisitorId(), 'SESSION' => $_SESSION, 'COOKIE' => $_COOKIE, 'GET' => $_GET, 'POST' => $_POST, 'SERVER' => $_SERVER));
    }

Usage Example

Beispiel #1
0
 /**
  * Initializes the entire frontend; preload FB, URL, template and the requested page.
  *
  * This method exists because the service container needs to be set before
  * the page's functionality gets loaded.
  */
 public function initialize()
 {
     new Url($this->getKernel());
     // Load the rest of the page.
     $this->page = new Page($this->getKernel());
     $this->page->load();
 }