You are here

PurgeUsersQueueWorker.php in Auto Purge Users 8.2

File

src/Plugin/QueueWorker/PurgeUsersQueueWorker.php
View source
<?php

namespace Drupal\purge_users\Plugin\QueueWorker;

use Drupal\Core\Queue\QueueWorkerBase;
use Drupal\user\Entity\User;

/**
 * Processes cron queue.
 *
 * @QueueWorker(
 *   id = "purge_users",
 *   title = @Translation("Purge Users Tasks Worker: Purge Users"),
 *   cron = {"time" = 15}
 * )
 */
class PurgeUsersQueueWorker extends QueueWorkerBase {

  /**
   * {@inheritdoc}
   */
  public function processItem($user_id) {
    $account = User::load($user_id);
    $config = \Drupal::config('purge_users.settings');
    $method = $config
      ->get('purge_user_cancel_method') != 'user_cancel_site_policy' ? $config
      ->get('purge_user_cancel_method') : \Drupal::config('user.settings')
      ->get('cancel_method');
    $userManagement = \Drupal::service('purge_users.user_management');
    $userManagement
      ->purgeUser($account, $method);
  }

}

Classes

Namesort descending Description
PurgeUsersQueueWorker Processes cron queue.