1 path_layout_access.inc PathLayoutAccess::checkAccess()

Checks for access based on the available context.

Return value

boolean: The result of the access check.

Overrides LayoutAccess::checkAccess

File

core/modules/layout/plugins/access/path_layout_access.inc, line 34
Plugin to provide access control/visibility based on path.

Class

PathLayoutAccess
@file Plugin to provide access control/visibility based on path.

Code

function checkAccess() {
  $base_path = $_GET['q'];

  $path = backdrop_get_path_alias($base_path);
  $page_match = backdrop_match_path($path, $this->settings['paths']);

  // If there's a URL alias, we may still be at the un-aliased path
  // so check that as well.
  if ($path !== $base_path) {
    $page_match = $page_match || backdrop_match_path($base_path, $this->settings['paths']);
  }

  // When $this->settings['visibility_setting'] has a value of 0, the block is
  // displayed on all pages except those listed. When set to 1, it
  // is displayed only on those pages listed.
  if (!$this->settings['visibility_setting']) {
    $page_match = !$page_match;
  }

  return $page_match;
}