function AccessCheck::access

Same name in other branches
  1. 9 core/modules/system/tests/modules/menu_test/src/Access/AccessCheck.php \Drupal\menu_test\Access\AccessCheck::access()
  2. 8.9.x core/modules/system/tests/modules/menu_test/src/Access/AccessCheck.php \Drupal\menu_test\Access\AccessCheck::access()
  3. 10 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 50

Class

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

Namespace

Drupal\menu_test\Access

Code

public function access() {
    $result = AccessResult::allowedIf($this->requestStack
        ->getCurrentRequest()
        ->getSession()
        ->get('menu_test', 0) < 2);
    return $result->setCacheMaxAge(0);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.