UserEmailVerificationBlockAccount.php in User email verification 8
File
src/Plugin/QueueWorker/UserEmailVerificationBlockAccount.php
View source
<?php
namespace Drupal\user_email_verification\Plugin\QueueWorker;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Queue\QueueWorkerBase;
use Drupal\user_email_verification\UserEmailVerificationInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class UserEmailVerificationBlockAccount extends QueueWorkerBase implements ContainerFactoryPluginInterface {
protected $userEmailVerification;
protected $logger;
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;
}
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'));
}
public function processItem($data) {
foreach ($data as $uid) {
$this->userEmailVerification
->blockUserAccountById($uid);
}
$this->logger
->notice('Blocked users with IDs: %ids', [
'%ids' => implode(', ', $data),
]);
}
}