function DefinedTestAccessCheck::access

Same name in other branches
  1. 9 core/modules/system/tests/modules/router_test_directory/src/Access/DefinedTestAccessCheck.php \Drupal\router_test\Access\DefinedTestAccessCheck::access()
  2. 8.9.x core/modules/system/tests/modules/router_test_directory/src/Access/DefinedTestAccessCheck.php \Drupal\router_test\Access\DefinedTestAccessCheck::access()
  3. 11.x core/modules/system/tests/modules/router_test_directory/src/Access/DefinedTestAccessCheck.php \Drupal\router_test\Access\DefinedTestAccessCheck::access()

Checks access.

Parameters

\Symfony\Component\Routing\Route $route: The route to check against.

Return value

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

File

core/modules/system/tests/modules/router_test_directory/src/Access/DefinedTestAccessCheck.php, line 23

Class

DefinedTestAccessCheck
Defines an access checker similar to DefaultAccessCheck.

Namespace

Drupal\router_test\Access

Code

public function access(Route $route) {
    if ($route->getRequirement('_test_access') === 'TRUE') {
        return AccessResult::allowed();
    }
    elseif ($route->getRequirement('_test_access') === 'FALSE') {
        return AccessResult::forbidden();
    }
    else {
        return AccessResult::neutral();
    }
}

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