DefaultAccessCheck.php

Contains Drupal\Core\Access\DefaultAccessCheck.

Namespace

Drupal\Core\Access

File

drupal/core/lib/Drupal/Core/Access/DefaultAccessCheck.php
View source
<?php

/**
 * @file
 * Contains Drupal\Core\Access\DefaultAccessCheck.
 */
namespace Drupal\Core\Access;

use Symfony\Component\Routing\Route;
use Symfony\Component\HttpFoundation\Request;

/**
 * Allows access to routes to be controlled by an '_access' boolean parameter.
 */
class DefaultAccessCheck implements AccessCheckInterface {

  /**
   * Implements AccessCheckInterface::applies().
   */
  public function applies(Route $route) {
    return array_key_exists('_access', $route
      ->getRequirements());
  }

  /**
   * {@inheritdoc}
   */
  public function access(Route $route, Request $request) {
    if ($route
      ->getRequirement('_access') === 'TRUE') {
      return static::ALLOW;
    }
    elseif ($route
      ->getRequirement('_access') === 'FALSE') {
      return static::KILL;
    }
    else {
      return static::DENY;
    }
  }

}

Classes

Namesort descending Description
DefaultAccessCheck Allows access to routes to be controlled by an '_access' boolean parameter.