You are here

public static function WorkflowManager::cancelUser in Workflow 8

Implements hook_user_cancel().

Implements deprecated workflow_update_workflow_transition_history_uid().

" When cancelling the account " - Disable the account and keep its content. " - Disable the account and unpublish its content. " - Delete the account and make its content belong to the Anonymous user. " - Delete the account and its content. "This action cannot be undone.

Parameters

$edit:

\Drupal\Core\Session\AccountInterface $account:

string $method:

Overrides WorkflowManagerInterface::cancelUser

2 calls to WorkflowManager::cancelUser()
WorkflowManager::deleteUser in src/Entity/WorkflowManager.php
Implements hook_user_delete().
workflow_user_cancel in ./workflow.module
Implements hook_user_cancel().

File

src/Entity/WorkflowManager.php, line 301

Class

WorkflowManager
Manages entity type plugin definitions.

Namespace

Drupal\workflow\Entity

Code

public static function cancelUser($edit, AccountInterface $account, $method) {
  switch ($method) {
    case 'user_cancel_block':

    // Disable the account and keep its content.
    case 'user_cancel_block_unpublish':

      // Disable the account and unpublish its content.
      // Do nothing.
      break;
    case 'user_cancel_reassign':

    // Delete the account and make its content belong to the Anonymous user.
    case 'user_cancel_delete':

      // Delete the account and its content.

      /*
       * Update tables for deleted account, move account to user 0 (anon.)
       * ALERT: This may cause previously non-Anonymous posts to suddenly
       * be accessible to Anonymous.
       */

      /*
       * Given a user id, re-assign history to the new user account.
       * Called by user_delete().
       */
      $uid = $account
        ->id();
      $new_uid = 0;
      $database = \Drupal::database();
      $database
        ->update('workflow_transition_history')
        ->fields([
        'uid' => $new_uid,
      ])
        ->condition('uid', $uid, '=')
        ->execute();
      $database
        ->update('workflow_transition_schedule')
        ->fields([
        'uid' => $new_uid,
      ])
        ->condition('uid', $uid, '=')
        ->execute();
      break;
  }
}