You are here

public function AccessCheck::access in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/system/tests/modules/menu_test/src/Access/AccessCheck.php \Drupal\menu_test\Access\AccessCheck::access()

Check to see if user accessed this page.

Return value

\Drupal\Core\Access\AccessResultInterface The access result.

File

core/modules/system/tests/modules/menu_test/src/Access/AccessCheck.php, line 19

Class

AccessCheck
Checks access based on the 'menu_test' key in session.

Namespace

Drupal\menu_test\Access

Code

public function access() {
  if (!isset($_SESSION['menu_test'])) {
    $result = AccessResult::allowed();
  }
  else {
    $result = AccessResult::allowedIf($_SESSION['menu_test'] < 2);
  }
  return $result
    ->setCacheMaxAge(0);
}