You are here

public function ActionDelete::process in User Merge 2.x

Process merge on selected property.

Parameters

\Drupal\user\UserInterface $retired: Retired account.

\Drupal\user\UserInterface $retained: Retained account.

Throws

\Drupal\usermerge\Exception\UserMergeException

Overrides UserMergeActionPluginInterface::process

File

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

Class

ActionDelete
Class ActionDelete.

Namespace

Drupal\usermerge\Plugin\UserMerge\Action

Code

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.');
  }
}