You are here

class UserEmailVerificationDeleteAccount in User email verification 8

Delete user accounts which wasn't verified by cron.

Plugin annotation


@QueueWorker(
  id = "user_email_verification_delete_account",
  title = @Translation("User email verification: Delete user accounts"),
  cron = {"time" = 30}
)

Hierarchy

Expanded class hierarchy of UserEmailVerificationDeleteAccount

File

src/Plugin/QueueWorker/UserEmailVerificationDeleteAccount.php, line 20

Namespace

Drupal\user_email_verification\Plugin\QueueWorker
View source
class UserEmailVerificationDeleteAccount extends QueueWorkerBase implements ContainerFactoryPluginInterface {

  /**
   * User email verification helper service.
   *
   * @var \Drupal\user_email_verification\UserEmailVerificationInterface
   */
  protected $userEmailVerification;

  /**
   * A logger instance.
   *
   * @var \Psr\Log\LoggerInterface
   */
  protected $logger;

  /**
   * Constructs a new object.
   *
   * @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\user_email_verification\UserEmailVerificationInterface $user_email_verification_service
   *   User email verification helper service.
   * @param \Psr\Log\LoggerInterface $logger
   *   A logger instance.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, UserEmailVerificationInterface $user_email_verification_service, LoggerInterface $logger) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->userEmailVerification = $user_email_verification_service;
    $this->logger = $logger;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static($configuration, $plugin_id, $plugin_definition, $container
      ->get('user_email_verification.service'), $container
      ->get('logger.factory')
      ->get('user_email_verification'));
  }

  /**
   * {@inheritdoc}
   */
  public function processItem($data) {
    foreach ($data as $uid) {
      $this->userEmailVerification
        ->deleteUserAccountById($uid);
    }
    $this->logger
      ->notice('Deleted users with IDs: %ids', [
      '%ids' => implode(', ', $data),
    ]);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
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.
UserEmailVerificationDeleteAccount::$logger protected property A logger instance.
UserEmailVerificationDeleteAccount::$userEmailVerification protected property User email verification helper service.
UserEmailVerificationDeleteAccount::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create
UserEmailVerificationDeleteAccount::processItem public function Works on a single queue item. Overrides QueueWorkerInterface::processItem
UserEmailVerificationDeleteAccount::__construct public function Constructs a new object. Overrides PluginBase::__construct