Resolve #3526411 "Move hook map"
Closes #3526411
Merge request reports
Activity
Would be useful for !12156 so we dont need this kind of workaround: !12156 (9891c6b2)
22 foreach ($tags as &$tag) { 23 if ( 24 !array_key_exists('event', $tag) || 25 !array_key_exists('module', $tag) || 26 !str_starts_with($tag['event'], 'drupal_hook.') 27 ) { 28 continue; 29 } 30 31 [1 => $hook] = explode('.', $tag['event'], 2); 32 $class = $container->getDefinition($id)->getClass(); 33 $map[$hook][$class][$tag['method']] = $tag['module']; 34 } 35 } 36 37 $container->getDefinition('module_handler')->setArgument(3, $map); the argument name is
3
, not$hookImplementationsMap
orhookImplementationsMap
because the default[]
value is incore.services.yml
. The default is required in order to satisfy https://www.drupal.org/project/drupal/issues/2363351I did try this first, but you can see the recent failing pipelines were stopped on this.
Alternatively, we could redefine the core.services.yml entry with parameter name keys (YAML map?) instead of an array. But that would require renaming existing numerical keys there to their string/arg-name equivs.
Happy to be proven wrong on this.
Also this remains a very internal thing and shouldnt need an amazing DX.
With a named argument, the
$
prefix is necessary, so it would be$hookImplementationsMap
.See example: https://www.drupal.org/node/3218156
Edited by godotislate
- Resolved by dpi