You are here

public function Implement::execute in Drupal 7 to 8/9 Module Upgrader 8

Executes the plugin.

Overrides ExecutableInterface::execute

File

src/Plugin/DMU/Fixer/Implement.php, line 16

Class

Implement
Plugin annotation @Fixer( id = "implement" )

Namespace

Drupal\drupalmoduleupgrader\Plugin\DMU\Fixer

Code

public function execute() {

  /** @var \Pharborist\Objects\ClassNode $class */
  $class = $this->target
    ->getIndexer('class')
    ->get($this->configuration['target']);

  // Use reflection to get the method definition.
  list($interface, $method) = explode('::', $this->configuration['definition']);
  $interface = new \ReflectionClass($interface);
  $method = $interface
    ->getMethod($method);
  $node = ClassMethodNode::create($method
    ->getName());
  $node
    ->setDocComment(DocCommentNode::create('@inheritdoc'));
  $class
    ->appendMethod($node);
  $node
    ->matchReflector($method);

  // @TODO There needs to be a way to implement the method body!
  $this->target
    ->save($class);
}