protected function CheckProvider::applies

protected CheckProvider::applies(Route $route)

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.

File

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

Class

CheckProvider
Loads access checkers from the container.

Namespace

Drupal\Core\Access

Code

protected function applies(Route $route) {
  $checks = array();

  // 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) {
        $checks[] = $service_id;
      }
    }
  }
  // Finally, see if any dynamic access checkers apply.
  foreach ($this->dynamicRequirementMap as $service_id) {
    if ($this->checks[$service_id]->applies($route)) {
      $checks[] = $service_id;
    }
  }

  return $checks;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Access!CheckProvider.php/function/CheckProvider::applies/8.1.x