You are here

public function HookURLOutboundAlter::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/HookURLOutboundAlter.php, line 20

Class

HookURLOutboundAlter
Plugin annotation @Converter( id = "hook_url_outbound_alter", description = @Translation("Converts hook_url_outbound_alter() to a service."), hook = "hook_url_outbound_alter" )

Namespace

Drupal\drupalmoduleupgrader\Plugin\DMU\Converter

Code

public function convert(TargetInterface $target) {
  $this
    ->writeService($target, 'outbound_path_processor', [
    'class' => 'Drupal\\' . $target
      ->id() . '\\OutboundPathProcessor',
    'tags' => [
      [
        'name' => 'path_processor_outbound',
      ],
    ],
  ]);
  $render = [
    '#theme' => 'dmu_outbound_path_processor',
    '#module' => $target
      ->id(),
  ];
  $processor = $this
    ->parse($render);
  $target
    ->getIndexer('function')
    ->get('hook_url_outbound_alter')
    ->cloneAsMethodOf($processor)
    ->setName('processOutbound');
  $this
    ->writeClass($target, $processor);
}