function filebrowser_node_delete in Filebrowser 8.2
Same name and namespace in other branches
- 3.x filebrowser.module \filebrowser_node_delete()
Deletes an Metadata entity when its provider node gets deleted
Implements hook_entity_delete(). @inheritdoc
File
- ./
filebrowser.module, line 214
Code
function filebrowser_node_delete(NodeInterface $node) {
if ($node
->bundle() == 'dir_listing') {
// get all the entities for this node
$query = \Drupal::entityQuery('filebrowser_metadata_entity')
->condition('nid', $node
->id(), '=');
$ids = $query
->execute();
$storage = \Drupal::entityTypeManager()
->getStorage('filebrowser_metadata_entity');
$entities = $storage
->loadMultiple($ids);
if ($entities) {
foreach ($entities as $entity) {
$entity
->delete();
}
}
}
}