You are here

public function ConverterBase::writeClass in Drupal 7 to 8/9 Module Upgrader 8

Writes a class to the target module's PSR-4 root.

Parameters

TargetInterface $target: The target module.

\Pharborist\Objects\ClassNode $class: The class to write. The path will be determined from the class' fully qualified name.

Return value

string The generated path to the class.

14 calls to ConverterBase::writeClass()
Blocks::convert in src/Plugin/DMU/Converter/Blocks.php
Performs required conversions.
ContentRoute::buildRoute in src/Plugin/DMU/Routing/ContentRoute.php
Builds the Drupal 8 route, making any needed changes to the original module and/or callback.
FormRoute::buildRoute in src/Plugin/DMU/Routing/FormRoute.php
Builds the Drupal 8 route, making any needed changes to the original module and/or callback.
HookBoot::convert in src/Plugin/DMU/Converter/HookBoot.php
Performs required conversions.
HookEntityInfo::convert in src/Plugin/DMU/Converter/HookEntityInfo.php
Performs required conversions.

... See full list

File

src/ConverterBase.php, line 145

Class

ConverterBase
Base class for converters.

Namespace

Drupal\drupalmoduleupgrader

Code

public function writeClass(TargetInterface $target, ClassNode $class) {
  $class_path = ltrim($class
    ->getName()
    ->getAbsolutePath(), '\\');
  $path = str_replace([
    'Drupal\\' . $target
      ->id(),
    '\\',
  ], [
    'src',
    '/',
  ], $class_path) . '.php';
  return $this
    ->write($target, $path, $class
    ->parents()
    ->get(0));
}