You are here

public function EntityHook::onUserCancel in Editor Notes 8

Reassign Editor Note on user cancel.

Parameters

\Drupal\Core\Session\AccountInterface $account: User object.

See also

editor_note_user_cancel

File

src/Hook/EntityHook.php, line 126

Class

EntityHook
Be aware of some entity hooks to perform actions on editor note.

Namespace

Drupal\editor_note\Hook

Code

public function onUserCancel(AccountInterface $account) {
  $notes = $this->entityTypeManager
    ->getStorage('editor_note')
    ->loadByProperties([
    'uid' => $account
      ->id(),
  ]);
  foreach ($notes as $note) {

    // Assign to anonymous user.
    $note
      ->set('uid', 0);
    $note
      ->save();
  }
}