class PurgeUsersQueueWorker in Auto Purge Users 8.3
Same name and namespace in other branches
- 8 src/Plugin/QueueWorker/PurgeUsersQueueWorker.php \Drupal\purge_users\Plugin\QueueWorker\PurgeUsersQueueWorker
- 8.2 src/Plugin/QueueWorker/PurgeUsersQueueWorker.php \Drupal\purge_users\Plugin\QueueWorker\PurgeUsersQueueWorker
Processes cron queue.
Plugin annotation
@QueueWorker(
id = "purge_users",
title = @Translation("Purge Users Tasks Worker: Purge Users"),
cron = {"time" = 15}
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Queue\QueueWorkerBase implements QueueWorkerInterface
- class \Drupal\purge_users\Plugin\QueueWorker\PurgeUsersQueueWorker implements ContainerFactoryPluginInterface
- class \Drupal\Core\Queue\QueueWorkerBase implements QueueWorkerInterface
Expanded class hierarchy of PurgeUsersQueueWorker
File
- src/
Plugin/ QueueWorker/ PurgeUsersQueueWorker.php, line 23
Namespace
Drupal\purge_users\Plugin\QueueWorkerView source
class PurgeUsersQueueWorker extends QueueWorkerBase implements ContainerFactoryPluginInterface {
/**
* The purge user manager.
*
* @var \Drupal\purge_users\Services\UserManagementServiceInterface
*/
protected $purgeUserManager;
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* The configuration factory.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;
/**
* Constructs a new PurgeUsersQueueWorker instance.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\purge_users\Services\UserManagementServiceInterface $purge_user
* The purge user manager service.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager service.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory service.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, UserManagementServiceInterface $purge_user, EntityTypeManagerInterface $entity_type_manager, ConfigFactoryInterface $config_factory) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->purgeUserManager = $purge_user;
$this->entityTypeManager = $entity_type_manager;
$this->configFactory = $config_factory;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) : self {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('purge_users.user_management'), $container
->get('entity_type.manager'), $container
->get('config.factory'));
}
/**
* {@inheritdoc}
*/
public function processItem($user_id) {
$account = $this->entityTypeManager
->getStorage('user')
->load($user_id);
if (!$account) {
return;
}
$config = $this->configFactory
->get('purge_users.settings');
$method = $config
->get('purge_user_cancel_method') !== 'user_cancel_site_policy' ? $config
->get('purge_user_cancel_method') : $this->configFactory
->get('user.settings')
->get('cancel_method');
$this->purgeUserManager
->purgeUser($account, $method);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PurgeUsersQueueWorker:: |
protected | property | The configuration factory. | |
PurgeUsersQueueWorker:: |
protected | property | The entity type manager. | |
PurgeUsersQueueWorker:: |
protected | property | The purge user manager. | |
PurgeUsersQueueWorker:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
PurgeUsersQueueWorker:: |
public | function |
Works on a single queue item. Overrides QueueWorkerInterface:: |
|
PurgeUsersQueueWorker:: |
public | function |
Constructs a new PurgeUsersQueueWorker instance. Overrides PluginBase:: |