public function Classes::add in Drupal 7 to 8/9 Module Upgrader 8
Overrides IndexerBase::add
File
- src/
Plugin/ DMU/ Indexer/ Classes.php, line 39
Class
- Classes
- Plugin annotation @Indexer( id = "class" )
Namespace
Drupal\drupalmoduleupgrader\Plugin\DMU\IndexerCode
public function add(NodeInterface $node) {
$fields = [
'file' => $node
->getFilename(),
'type' => get_class($node),
];
if ($node instanceof ClassNode) {
$fields['id'] = (string) $node
->getName();
$fields['parent'] = (string) $node
->getExtends();
}
elseif ($node instanceof NewNode) {
$fields['id'] = (string) $node
->getClassName();
}
else {
throw new \InvalidArgumentException('Unexpected node type (expected ClassNode or NewNode).');
}
$this->db
->insert($this->table)
->fields($fields)
->execute();
}