You are here

class MassPasswordReset in Mass Password Change 8

Same name in this branch
  1. 8 tests/src/Functional/MassPasswordReset.php \Drupal\Tests\mass_password_change\Functional\MassPasswordReset
  2. 8 src/Plugin/Action/MassPasswordReset.php \Drupal\mass_password_change\Plugin\Action\MassPasswordReset

Provides a Password reset action.

Plugin annotation


@Action(
  id = "mass_password_reset_action",
  label = @Translation("Password reset"),
  type = "user",
  confirm_form_route_name = "mass_password_change.password_reset_confirm",
)

Hierarchy

Expanded class hierarchy of MassPasswordReset

File

src/Plugin/Action/MassPasswordReset.php, line 21

Namespace

Drupal\mass_password_change\Plugin\Action
View source
class MassPasswordReset extends ActionBase implements ContainerFactoryPluginInterface {

  /**
   * Private TempStore Factory.
   *
   * @var \Drupal\Core\TempStore\PrivateTempStoreFactory
   */
  protected $tempStoreFactory;

  /**
   * MassPasswordReset constructor.
   *
   * @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\Core\TempStore\PrivateTempStoreFactory $tempStoreFactory
   *   Private TempStore Factory.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, PrivateTempStoreFactory $tempStoreFactory) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->tempStoreFactory = $tempStoreFactory;
  }

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

  /**
   * {@inheritdoc}
   */
  public function access($user, AccountInterface $account = NULL, $return_as_object = FALSE) {

    /** @var \Drupal\user\UserInterface $user */

    // Prevent uid=1 user or disallow current user, blocked user.
    return $user
      ->id() != 1 && $user
      ->id() != $account
      ->id() && !$user
      ->isBlocked();
  }

  /**
   * {@inheritdoc}
   */
  public function executeMultiple(array $accounts) {

    /** @var \Drupal\user\UserInterface[] $accounts */
    $this->tempStoreFactory
      ->get('mass_password_change')
      ->set('password_reset', $accounts);
  }

  /**
   * {@inheritdoc}
   */
  public function execute($account = NULL) {

    /** @var \Drupal\user\UserInterface $account */
    $this
      ->executeMultiple([
      $account,
    ]);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
MassPasswordReset::$tempStoreFactory protected property Private TempStore Factory.
MassPasswordReset::access public function Checks object access. Overrides ActionInterface::access
MassPasswordReset::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create
MassPasswordReset::execute public function Executes the plugin. Overrides ExecutableInterface::execute
MassPasswordReset::executeMultiple public function Executes the plugin for an array of objects. Overrides ActionBase::executeMultiple
MassPasswordReset::__construct public function MassPasswordReset constructor. Overrides PluginBase::__construct
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
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.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.