You are here

function popup_onload_check_path in Popup On Load 8

Same name and namespace in other branches
  1. 7 popup_onload.module \popup_onload_check_path()

Checks whether the current path is included in popup settings.

1 call to popup_onload_check_path()
PopupOnloadController::getPopup in src/Controller/PopupOnloadController.php
Get popup.

File

./popup_onload.module, line 85
Contains main popup_onload hooks and functions.

Code

function popup_onload_check_path($path) {
  $page_match = FALSE;
  if (!empty($path)) {
    $path = mb_strtolower($path);

    // Further processing came from the blocks module.
    // Convert the Drupal path to lowercase.
    $current_path = \Drupal::request()
      ->get('path');

    // Compare the lowercase internal and lowercase path alias (if any).
    $page_match = \Drupal::service('path.matcher')
      ->matchPath($path, $current_path);
  }
  else {
    $request = Request::create(\Drupal::request()
      ->get('path'));
    $route_match = \Drupal::service('router.no_access_checks')
      ->matchRequest($request);
    $route = $route_match[RouteObjectInterface::ROUTE_OBJECT];
    $page_match = !\Drupal::service('router.admin_context')
      ->isAdminRoute($route);
  }
  return $page_match;
}