public function HookMenuAlter::convert in Drupal 7 to 8/9 Module Upgrader 8
Performs required conversions.
Parameters
TargetInterface $target: The target module to convert.
Overrides ConverterInterface::convert
File
- src/
Plugin/ DMU/ Converter/ HookMenuAlter.php, line 46
Class
- HookMenuAlter
- Plugin annotation @Converter( id = "hook_menu_alter", description = @Translation("Creates boilerplate for logic that formerly belonged in hook_menu_alter()."), hook = "hook_menu_alter", fixme = @Translation("hook_menu_alter() is gone in Drupal 8.…
Namespace
Drupal\drupalmoduleupgrader\Plugin\DMU\ConverterCode
public function convert(TargetInterface $target) {
$target
->getIndexer('function')
->get($this->pluginDefinition['hook'])
->setDocComment($this
->buildFixMe(NULL, [], self::DOC_COMMENT));
$render = [
'#theme' => 'dmu_route_subscriber',
'#module' => $target
->id(),
];
$this
->writeClass($target, $this
->parse($render));
$alterable = ParameterNode::create('data');
$alterable
->setTypeHint('array')
->setReference(TRUE);
$parameter = clone $alterable;
$this
->implement($target, 'menu_links_discovered_alter')
->appendParameter($parameter
->setName('links'));
$parameter = clone $alterable;
$this
->implement($target, 'menu_local_tasks_alter')
->appendParameter($parameter
->setName('data'))
->appendParameter(ParameterNode::create('route_name'));
$parameter = clone $alterable;
$this
->implement($target, 'menu_local_actions_alter')
->appendParameter($parameter
->setName('local_actions'));
$parameter = clone $alterable;
$items = clone $alterable;
$function = $this
->implement($target, 'contextual_links_view_alter')
->appendParameter($parameter
->setName('element'))
->appendParameter($items
->setName('items')
->setReference(FALSE));
$target
->save($function);
}