3 namespace Drupal\Core\DependencyInjection\Compiler;
5 use Symfony\Component\DependencyInjection\ContainerBuilder;
6 use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
9 * Adds services tagged 'access_check' to the access_manager service.
11 class RegisterAccessChecksPass implements CompilerPassInterface {
16 public function process(ContainerBuilder $container) {
17 if (!$container->hasDefinition('access_manager')) {
20 // Add services tagged 'access_check' to the access_manager service.
21 $access_manager = $container->getDefinition('access_manager.check_provider');
22 foreach ($container->findTaggedServiceIds('access_check') as $id => $attributes) {
25 $needs_incoming_request = FALSE;
26 foreach ($attributes as $attribute) {
27 if (isset($attribute['applies_to'])) {
28 $applies[] = $attribute['applies_to'];
30 if (isset($attribute['method'])) {
31 $method = $attribute['method'];
33 if (!empty($attribute['needs_incoming_request'])) {
34 $needs_incoming_request = TRUE;
37 $access_manager->addMethodCall('addCheckService', [$id, $method, $applies, $needs_incoming_request]);