function node_user_predelete in Drupal 8
Same name and namespace in other branches
- 9 core/modules/node/node.module \node_user_predelete()
Implements hook_ENTITY_TYPE_predelete() for user entities.
File
- core/
modules/ node/ node.module, line 789 - The core module that allows content to be submitted to the site.
Code
function node_user_predelete($account) {
// Delete nodes (current revisions).
// @todo Introduce node_mass_delete() or make node_mass_update() more flexible.
$nids = \Drupal::entityQuery('node')
->condition('uid', $account
->id())
->accessCheck(FALSE)
->execute();
// Delete old revisions.
$storage_controller = \Drupal::entityTypeManager()
->getStorage('node');
$nodes = $storage_controller
->loadMultiple($nids);
$storage_controller
->delete($nodes);
$revisions = $storage_controller
->userRevisionIds($account);
foreach ($revisions as $revision) {
node_revision_delete($revision);
}
}