protected function DrupalmoduleupgraderCommands::dmuGetDirectory in Drupal 7 to 8/9 Module Upgrader 8
Determines the path to a module.
Parameters
string $module: Module name.
Return value
mixed|null Module path if find or null.
2 calls to DrupalmoduleupgraderCommands::dmuGetDirectory()
- DrupalmoduleupgraderCommands::dmuBuildTarget in src/
Commands/ DrupalmoduleupgraderCommands.php - Builds target module.
- DrupalmoduleupgraderCommands::upgrade in src/
Commands/ DrupalmoduleupgraderCommands.php - Upgrades a Drupal 7 module to Drupal 8 or Drupal 9.
File
- src/
Commands/ DrupalmoduleupgraderCommands.php, line 208
Class
Namespace
Drupal\drupalmoduleupgrader\CommandsCode
protected function dmuGetDirectory(string $module) {
// Use Unix paths regardless of platform, skip dot directories, follow
// symlinks (to allow extensions to be linked from elsewhere), and return
// the RecursiveDirectoryIterator instance to have access to getSubPath(),
// since SplFileInfo does not support relative paths.
$flags = \FilesystemIterator::UNIX_PATHS;
$flags |= \FilesystemIterator::SKIP_DOTS;
$flags |= \FilesystemIterator::FOLLOW_SYMLINKS;
$flags |= \FilesystemIterator::CURRENT_AS_SELF;
$directory_iterator1 = new \RecursiveDirectoryIterator(DRUPAL_ROOT . '/modules', $flags);
$directory_iterator2 = new \RecursiveDirectoryIterator(DRUPAL_ROOT . '/sites', $flags);
$iterator = new \AppendIterator();
$iterator
->append(new \RecursiveIteratorIterator($directory_iterator1));
$iterator
->append(new \RecursiveIteratorIterator($directory_iterator2));
$path = NULL;
foreach ($iterator as $file) {
if ($file
->getFileName() === $module . '.info') {
$path = rtrim(str_replace($module . '.info', '', $file
->getPathName()), '/');
}
}
return $path;
}