function NodeUserHooks::userCancelBlockUnpublish

Implements hook_user_cancel().

Unpublish nodes (current revisions).

Attributes

File

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

Class

NodeUserHooks
Hook implementations for the node module.

Namespace

Drupal\node\Hook

Code

public function userCancelBlockUnpublish($edit, UserInterface $account, $method) : void {
  if ($method === 'user_cancel_block_unpublish') {
    $nids = $this->entityTypeManager
      ->getStorage('node')
      ->getQuery()
      ->accessCheck(FALSE)
      ->condition('uid', $account->id())
      ->execute();
    $this->nodeBulkUpdate
      ->process($nids, [
      'status' => 0,
    ], NULL, TRUE);
  }
}

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