You are here

class ActionDelete in User Merge 2.x

Class ActionDelete.

@UserMergeAction( id = "action_delete", name = @Translation("Delete retired account"), )

@package Drupal\usermerge\Plugin\UserMerge\Action

Hierarchy

Expanded class hierarchy of ActionDelete

File

src/Plugin/UserMerge/Action/ActionDelete.php, line 19

Namespace

Drupal\usermerge\Plugin\UserMerge\Action
View source
class ActionDelete extends UserMergeActionBase {

  /**
   * {@inheritDoc}
   */
  public function process(UserInterface $retired, UserInterface $retained) : void {
    if ($retired
      ->id() == 1) {
      throw new UserMergeException('You can not retire user 1.');
    }
    if ($retired
      ->id() == $this->currentUser
      ->id()) {
      throw new UserMergeException('You can not retire self.');
    }
    try {
      $retired
        ->delete();
    } catch (EntityStorageException $e) {
      throw new UserMergeException('An error occurred during deletion.');
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ActionDelete::process public function Process merge on selected property. Overrides UserMergeActionPluginInterface::process
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 2
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.
UserMergeActionBase::$currentUser protected property The current user.
UserMergeActionBase::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create
UserMergeActionBase::getName public function Return the name of the action merge plugin. Overrides UserMergeActionPluginInterface::getName
UserMergeActionBase::__construct public function UserMergeActionBase constructor. Overrides PluginBase::__construct