You are here

public function InstapageCmsPluginDrupal8Connector::checkHomepage in Instapage plugin 8.3

Same name and namespace in other branches
  1. 7.3 core/connectors/InstapageCmsPluginDrupal8Connector.php \InstapageCmsPluginDrupal8Connector::checkHomepage()

Checks (and displays) if a landing page marked as homepage should be displayed instead of normal CMS homepage.

@uses InstapageCmsPluginDrupal8Connector::checkPage()

1 call to InstapageCmsPluginDrupal8Connector::checkHomepage()
InstapageCmsPluginDrupal8Connector::initPlugin in core/connectors/InstapageCmsPluginDrupal8Connector.php
Initiates Instapage plugin's DB structure and loads plugin's classes.

File

core/connectors/InstapageCmsPluginDrupal8Connector.php, line 524

Class

InstapageCmsPluginDrupal8Connector
Class that utilizes native Drupal 8 functions to perform actions like remote requests and DB operations.

Code

public function checkHomepage() {
  $homeUrl = str_replace(array(
    'http://',
    'https://',
  ), '', rtrim($this
    ->getHomeURL(), '/'));
  $homeUrlSegments = explode('/', $homeUrl);
  $uriSegments = explode('?', $_SERVER['REQUEST_URI']);
  $uriSegments = explode('/', rtrim($uriSegments[0], '/'));
  if (count($uriSegments) !== count($homeUrlSegments) || count($homeUrlSegments) > 1 && $homeUrlSegments[1] != $uriSegments[1]) {
    return false;
  }
  $this
    ->checkPage('home');
  return true;
}