function CheckProvider::applies

Same name in other branches
  1. 9 core/lib/Drupal/Core/Access/CheckProvider.php \Drupal\Core\Access\CheckProvider::applies()
  2. 8.9.x core/lib/Drupal/Core/Access/CheckProvider.php \Drupal\Core\Access\CheckProvider::applies()
  3. 10 core/lib/Drupal/Core/Access/CheckProvider.php \Drupal\Core\Access\CheckProvider::applies()

Determine which registered access checks apply to a route.

Parameters

\Symfony\Component\Routing\Route $route: The route to get list of access checks for.

Return value

array An array of service ids for the access checks that apply to passed route.

1 call to CheckProvider::applies()
CheckProvider::setChecks in core/lib/Drupal/Core/Access/CheckProvider.php

File

core/lib/Drupal/Core/Access/CheckProvider.php, line 137

Class

CheckProvider
Loads access checkers from the container.

Namespace

Drupal\Core\Access

Code

protected function applies(Route $route) {
    $checks = [];
    // Iterate through map requirements from appliesTo() on access checkers.
    // Only iterate through all checkIds if this is not used.
    foreach ($route->getRequirements() as $key => $value) {
        if (isset($this->staticRequirementMap[$key])) {
            foreach ($this->staticRequirementMap[$key] as $service_id) {
                $this->loadCheck($service_id);
                $checks[] = $service_id;
            }
        }
    }
    // Finally, see if any dynamic access checkers apply.
    foreach ($this->dynamicRequirementMap as $service_id) {
        $this->loadCheck($service_id);
        if ($this->checks[$service_id]
            ->applies($route)) {
            $checks[] = $service_id;
        }
    }
    return $checks;
}

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