class RegisterAccessChecksPass
Same name in other branches
- 9 core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterAccessChecksPass.php \Drupal\Core\DependencyInjection\Compiler\RegisterAccessChecksPass
- 8.9.x core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterAccessChecksPass.php \Drupal\Core\DependencyInjection\Compiler\RegisterAccessChecksPass
- 10 core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterAccessChecksPass.php \Drupal\Core\DependencyInjection\Compiler\RegisterAccessChecksPass
Adds services tagged 'access_check' to the access_manager service.
Hierarchy
- class \Drupal\Core\DependencyInjection\Compiler\RegisterAccessChecksPass implements \Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface
Expanded class hierarchy of RegisterAccessChecksPass
1 file declares its use of RegisterAccessChecksPass
- CoreServiceProvider.php in core/
lib/ Drupal/ Core/ CoreServiceProvider.php
File
-
core/
lib/ Drupal/ Core/ DependencyInjection/ Compiler/ RegisterAccessChecksPass.php, line 14
Namespace
Drupal\Core\DependencyInjection\CompilerView source
class RegisterAccessChecksPass implements CompilerPassInterface {
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container) : void {
if (!$container->hasDefinition('access_manager')) {
return;
}
$services = [];
$dynamic_access_check_services = [];
// 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 = [];
$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', [
$id,
$method,
$applies,
$needs_incoming_request,
]);
// Collect dynamic access checker services.
$class = $container->getDefinition($id)
->getClass();
if (in_array(AccessCheckInterface::class, class_implements($class), TRUE)) {
$dynamic_access_check_services[] = $id;
}
$services[$id] = new Reference($id);
}
$access_manager->addArgument(ServiceLocatorTagPass::register($container, $services));
$container->setParameter('dynamic_access_check_services', $dynamic_access_check_services);
}
}
Members
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.