function NodeUserHooks::userCancelReassign

Implements hook_user_cancel().

Anonymize all of the nodes for this old account.

Attributes

File

core/modules/node/src/Hook/NodeUserHooks.php, line 47

Class

NodeUserHooks
Hook implementations for the node module.

Namespace

Drupal\node\Hook

Code

public function userCancelReassign($edit, UserInterface $account, $method) : void {
  if ($method === 'user_cancel_reassign') {
    $query = $this->entityTypeManager
      ->getStorage('node')
      ->getQuery()
      ->allRevisions()
      ->accessCheck(FALSE)
      ->condition('uid', $account->id());
    $vids = array_keys($query->execute());
    $this->nodeBulkUpdate
      ->process($vids, [
      'uid' => 0,
      'revision_uid' => 0,
    ], NULL, TRUE, TRUE);
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.