public static function PSR4::toPSR4 in Drupal 7 to 8/9 Module Upgrader 8
Utility method to PSR4-ify a class. It'll move the class into its own file in the given module's namespace. The class is modified in-place, so you should clone it before calling this function if you want to make a PSR-4 *copy* of it.
Parameters
\Drupal\drupalmoduleupgrader\TargetInterface $target: The module which will own the class.
\Pharborist\ClassNode $class: The class to modify.
Return value
\Pharborist\ClassNode The modified class, returned for convenience.
2 calls to PSR4::toPSR4()
- HookEntityInfo::convert in src/
Plugin/ DMU/ Converter/ HookEntityInfo.php - Performs required conversions.
- PSR4::convert in src/
Plugin/ DMU/ Converter/ PSR4.php - Performs required conversions.
File
- src/
Plugin/ DMU/ Converter/ PSR4.php, line 52
Class
- PSR4
- Plugin annotation @Converter( id = "PSR4", description = @Translation("Moves classes into PSR-4 directory structure.") )
Namespace
Drupal\drupalmoduleupgrader\Plugin\DMU\ConverterCode
public static function toPSR4(TargetInterface $target, ClassNode $class) {
$ns = 'Drupal\\' . $target
->id();
RootNode::create($ns)
->getNamespace($ns)
->append($class
->remove());
WhitespaceNode::create("\n\n")
->insertBefore($class);
return $class;
}