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. 10 core/modules/system/tests/modules/menu_test/src/Access/AccessCheck.php \Drupal\menu_test\Access\AccessCheck::access()
  3. 11.x 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);
}

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