MassPasswordChange.php in Mass Password Change 8
File
src/Plugin/Action/MassPasswordChange.php
View source
<?php
namespace Drupal\mass_password_change\Plugin\Action;
use Drupal\Core\Action\ActionBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\TempStore\PrivateTempStoreFactory;
use Symfony\Component\DependencyInjection\ContainerInterface;
class MassPasswordChange extends ActionBase implements ContainerFactoryPluginInterface {
protected $tempStoreFactory;
public function __construct(array $configuration, $plugin_id, $plugin_definition, PrivateTempStoreFactory $tempStoreFactory) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->tempStoreFactory = $tempStoreFactory;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('tempstore.private'));
}
public function access($user, AccountInterface $account = NULL, $return_as_object = FALSE) {
return $user
->id() != 1 && $user
->id() != $account
->id();
}
public function executeMultiple(array $accounts) {
$this->tempStoreFactory
->get('mass_password_change')
->set('password_change', $accounts);
}
public function execute($account = NULL) {
$this
->executeMultiple([
$account,
]);
}
}