class DefinedTestAccessCheck

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

Defines an access checker similar to DefaultAccessCheck

Hierarchy

Expanded class hierarchy of DefinedTestAccessCheck

1 file declares its use of DefinedTestAccessCheck
AccessManagerTest.php in core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php
Contains \Drupal\Tests\Core\Access\AccessManagerTest.

File

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

Namespace

Drupal\router_test\Access
View source
class DefinedTestAccessCheck implements AccessInterface {
    
    /**
     * Checks access.
     *
     * @param \Symfony\Component\Routing\Route $route
     *   The route to check against.
     *
     * @return \Drupal\Core\Access\AccessResultInterface
     *   The access result.
     */
    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();
        }
    }

}

Members

Title Sort descending Modifiers Object type Summary
DefinedTestAccessCheck::access public function Checks access.

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