You are here

public function DefinedTestAccessCheck::access in Drupal 9

Same name and namespace in other branches
  1. 8 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();
  }
}