You are here

DrupalGetTitle.php in Drupal 7 to 8/9 Module Upgrader 8

File

src/Plugin/DMU/Converter/Functions/DrupalGetTitle.php
View source
<?php

namespace Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\Functions;

use Drupal\drupalmoduleupgrader\TargetInterface;
use Pharborist\Functions\FunctionCallNode;
use Pharborist\Objects\ClassMethodCallNode;

/**
 * @Converter(
 *  id = "drupal_get_title",
 *  description = @Translation("Rewrites calls to drupal_get_title().")
 * )
 */
class DrupalGetTitle extends FunctionCallModifier {

  /**
   * {@inheritdoc}
   */
  public function rewrite(FunctionCallNode $call, TargetInterface $target) {
    return ClassMethodCallNode::create('\\Drupal', 'service')
      ->appendArgument('title_resolver')
      ->appendMethodCall('getTitle')
      ->appendArgument(ClassMethodCallNode::create('\\Drupal', 'request'))
      ->appendArgument(ClassMethodCallNode::create('\\Drupal', 'routeMatch')
      ->appendMethodCall('getRouteObject'));
  }

}

Classes

Namesort descending Description
DrupalGetTitle Plugin annotation @Converter( id = "drupal_get_title", description = @Translation("Rewrites calls to drupal_get_title().") )