RegisterAccessChecksPass::process

public RegisterAccessChecksPass::process(ContainerBuilder $container)

You can modify the container here before it is dumped to PHP code.

Parameters

ContainerBuilder $container:

Overrides CompilerPassInterface::process

File

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

Class

RegisterAccessChecksPass
Adds services tagged 'access_check' to the access_manager service.

Namespace

Drupal\Core\DependencyInjection\Compiler

Code

public function process(ContainerBuilder $container) {
  if (!$container->hasDefinition('access_manager')) {
    return;
  }
  // Add services tagged 'access_check' to the access_manager service.
  $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));
  }
}
doc_Drupal
2016-10-29 09:37:05
Comments
Leave a Comment

Please login to continue.