public function Target::id in Drupal 7 to 8/9 Module Upgrader 8
Returns the machine name of the target module.
Return value
string
Overrides TargetInterface::id
2 calls to Target::id()
- Target::executeHook in src/
Target.php - Executes a hook implementation and returns the result.
- Target::getPath in src/
Target.php - Returns the path to a particular file, relative to the CWD.
File
- src/
Target.php, line 76
Class
- Target
- Default implementation of TargetInterface.
Namespace
Drupal\drupalmoduleupgraderCode
public function id() {
if (empty($this->id)) {
$dir = $this
->getBasePath();
$info = (new Finder())
->in($dir)
->depth('== 0')
->name('*.info')
->getIterator();
$info
->rewind();
if ($info_file = $info
->current()) {
$this->id = substr($info_file
->getFilename(), 0, -5);
}
else {
throw new \RuntimeException((new FormattableMarkup('Could not find info file in @dir', [
'@dir' => $dir,
]))
->__toString());
}
}
return $this->id;
}