Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. CheckProvider.php

function CheckProvider::loadCheck

Overrides CheckProviderInterface::loadCheck

1 call to CheckProvider::loadCheck()
CheckProvider::applies in core/lib/Drupal/Core/Access/CheckProvider.php
Determine which registered access checks apply to a route.

File

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

Class

CheckProvider
Loads access checkers from the container.

Namespace

Drupal\Core\Access

Code

public function loadCheck($service_id) {
    if (empty($this->checks[$service_id])) {
        if (!in_array($service_id, $this->checkIds)) {
            throw new \InvalidArgumentException(sprintf('No check has been registered for %s', $service_id));
        }
        $check = $this->container
            ->get($service_id);
        if (!$check instanceof AccessInterface) {
            throw new AccessException('All access checks must implement AccessInterface.');
        }
        if (!is_callable([
            $check,
            $this->checkMethods[$service_id],
        ])) {
            throw new AccessException(sprintf('Access check method %s in service %s must be callable.', $this->checkMethods[$service_id], $service_id));
        }
        $this->checks[$service_id] = $check;
    }
    return [
        $this->checks[$service_id],
        $this->checkMethods[$service_id],
    ];
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal