function NodeHooks::userCancelBlockUnpublish

Implements hook_user_cancel().

Unpublish nodes (current revisions).

File

core/modules/node/src/Hook/NodeHooks.php, line 45

Class

NodeHooks
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->nodeStorage
            ->getQuery()
            ->accessCheck(FALSE)
            ->condition('uid', $account->id())
            ->execute();
        $this->moduleHandler
            ->invoke('node', 'mass_update', [
            $nids,
            [
                'status' => 0,
            ],
            NULL,
            TRUE,
        ]);
    }
}

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