class DefaultAccessCheck

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Access/DefaultAccessCheck.php \Drupal\Core\Access\DefaultAccessCheck
  2. 10 core/lib/Drupal/Core/Access/DefaultAccessCheck.php \Drupal\Core\Access\DefaultAccessCheck
  3. 11.x core/lib/Drupal/Core/Access/DefaultAccessCheck.php \Drupal\Core\Access\DefaultAccessCheck

Allows access to routes to be controlled by an '_access' boolean parameter.

Hierarchy

Expanded class hierarchy of DefaultAccessCheck

2 files declare their use of DefaultAccessCheck
AccessManagerTest.php in core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php
Contains \Drupal\Tests\Core\Access\AccessManagerTest.
DefaultAccessCheckTest.php in core/tests/Drupal/Tests/Core/Access/DefaultAccessCheckTest.php
1 string reference to 'DefaultAccessCheck'
core.services.yml in core/core.services.yml
core/core.services.yml
1 service uses DefaultAccessCheck
access_check.default in core/core.services.yml
Drupal\Core\Access\DefaultAccessCheck

File

core/lib/Drupal/Core/Access/DefaultAccessCheck.php, line 11

Namespace

Drupal\Core\Access
View source
class DefaultAccessCheck implements RoutingAccessInterface {
    
    /**
     * Checks access to the route based on the _access parameter.
     *
     * @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('_access') === 'TRUE') {
            return AccessResult::allowed();
        }
        elseif ($route->getRequirement('_access') === 'FALSE') {
            return AccessResult::forbidden();
        }
        else {
            return AccessResult::neutral();
        }
    }

}

Members

Title Sort descending Modifiers Object type Summary
DefaultAccessCheck::access public function Checks access to the route based on the _access parameter.

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