You are here

class RegisterAccessChecksPass in Service Container 7

Same name and namespace in other branches
  1. 7.2 lib/Drupal/Core/DependencyInjection/Compiler/RegisterAccessChecksPass.php \Drupal\Core\DependencyInjection\Compiler\RegisterAccessChecksPass

Adds services tagged 'access_check' to the access_manager service.

Hierarchy

Expanded class hierarchy of RegisterAccessChecksPass

File

lib/Drupal/Core/DependencyInjection/Compiler/RegisterAccessChecksPass.php, line 16
Contains \Drupal\Core\DependencyInjection\Compiler\RegisterAccessChecksPass.

Namespace

Drupal\Core\DependencyInjection\Compiler
View source
class RegisterAccessChecksPass implements CompilerPassInterface {

  /**
   * Implements CompilerPassInterface::process().
   *
   * Adds services tagged 'access_check' to the access_manager service.
   */
  public function process(ContainerBuilder $container) {
    if (!$container
      ->hasDefinition('access_manager')) {
      return;
    }
    $access_manager = $container
      ->getDefinition('access_manager.check_provider');
    foreach ($container
      ->findTaggedServiceIds('access_check') as $id => $attributes) {
      $applies = array();
      $method = 'access';
      $needs_incoming_request = FALSE;
      foreach ($attributes as $attribute) {
        if (isset($attribute['applies_to'])) {
          $applies[] = $attribute['applies_to'];
        }
        if (isset($attribute['method'])) {
          $method = $attribute['method'];
        }
        if (!empty($attribute['needs_incoming_request'])) {
          $needs_incoming_request = TRUE;
        }
      }
      $access_manager
        ->addMethodCall('addCheckService', array(
        $id,
        $method,
        $applies,
        $needs_incoming_request,
      ));
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RegisterAccessChecksPass::process public function Implements CompilerPassInterface::process(). Overrides CompilerPassInterface::process