public function ActionBlock::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/ ActionBlock.php, line 24
Class
- ActionBlock
- Class ActionBlock.
Namespace
Drupal\usermerge\Plugin\UserMerge\ActionCode
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.');
}
if (!$retired
->isActive()) {
throw new UserMergeException('The retire user is already blocked.');
}
try {
$retired
->block();
$retired
->save();
} catch (EntityStorageException $e) {
throw new UserMergeException('Am error occurred during status change.');
}
}