public function Target::getFileOf in Drupal 7 to 8/9 Module Upgrader 8
Determines which currently-open file a node belongs to, if any. Nodes which are not part of any open syntax tree will return NULL.
Return value
string|null
1 call to Target::getFileOf()
- Target::save in src/
Target.php - Saves the file in which a particular node appears.
File
- src/
Target.php, line 260
Class
- Target
- Default implementation of TargetInterface.
Namespace
Drupal\drupalmoduleupgraderCode
public function getFileOf(Node $node) {
if ($node instanceof RootNode) {
$root = $node;
}
else {
$parents = $node
->parents();
if ($parents
->isEmpty()) {
return NULL;
}
$root = $parents
->get(0);
}
foreach ($this->documents as $file => $doc) {
if ($root === $doc) {
return $file;
}
}
}