You are here

class NotifyUsersQueueWorker in Auto Purge Users 8.3

Processes cron queue.

Plugin annotation


@QueueWorker(
  id = "notification_users",
  title = @Translation("Notify Users Tasks Worker: Notification Users"),
  cron = {"time" = 15}
)

Hierarchy

Expanded class hierarchy of NotifyUsersQueueWorker

File

src/Plugin/QueueWorker/NotifyUsersQueueWorker.php, line 22

Namespace

Drupal\purge_users\Plugin\QueueWorker
View source
class NotifyUsersQueueWorker 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;

  /**
   * Constructs a new NotifyUsersQueueWorker 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.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, UserManagementServiceInterface $purge_user, EntityTypeManagerInterface $entity_type_manager) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->purgeUserManager = $purge_user;
    $this->entityTypeManager = $entity_type_manager;
  }

  /**
   * {@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'));
  }

  /**
   * {@inheritdoc}
   */
  public function processItem($user_id) : void {
    $account = $this->entityTypeManager
      ->getStorage('user')
      ->load($user_id);
    if (!$account) {
      return;
    }
    $this->purgeUserManager
      ->notifyUser($account);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
NotifyUsersQueueWorker::$entityTypeManager protected property The entity type manager.
NotifyUsersQueueWorker::$purgeUserManager protected property The purge user manager.
NotifyUsersQueueWorker::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create
NotifyUsersQueueWorker::processItem public function Works on a single queue item. Overrides QueueWorkerInterface::processItem
NotifyUsersQueueWorker::__construct public function Constructs a new NotifyUsersQueueWorker instance. Overrides PluginBase::__construct
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.