class UserMerger in User Merge 2.x
A service for merging two Drupal user accounts.
Hierarchy
- class \Drupal\usermerge\UserMerger implements UserMergerInterface
Expanded class hierarchy of UserMerger
1 string reference to 'UserMerger'
1 service uses UserMerger
File
- src/
UserMerger.php, line 11
Namespace
Drupal\usermergeView source
class UserMerger implements UserMergerInterface {
/**
* Property plugin manager.
*
* @var \Drupal\Component\Plugin\PluginManagerInterface
*/
protected $propertyPluginManager;
/**
* Action plugin manager.
*
* @var \Drupal\Component\Plugin\PluginManagerInterface
*/
protected $actionPluginManager;
/**
* Creates a user merger object.
*
* @param \Drupal\Component\Plugin\PluginManagerInterface $property_manager
* Property plugin manager.
* @param \Drupal\Component\Plugin\PluginManagerInterface $action_manager
* Action plugin manager.
*/
public function __construct(PluginManagerInterface $property_manager, PluginManagerInterface $action_manager) {
$this->propertyPluginManager = $property_manager;
$this->actionPluginManager = $action_manager;
}
/**
* {@inheritdoc}
*/
public function merge(UserInterface $retire_user, UserInterface $retain_user, $action_id = 'action_block') {
$this
->applyAction($action_id, $retire_user, $retain_user);
foreach ($this
->getPropertyPlugins() as $plugin_id) {
$this
->applyProperty($plugin_id, $retire_user, $retain_user);
}
return $retain_user;
}
/**
* {@inheritdoc}
*/
public function applyAction($plugin_id, UserInterface $retire_user, UserInterface $retain_user) {
$this->actionPluginManager
->createInstance($plugin_id)
->process($retire_user, $retain_user);
}
/**
* {@inheritdoc}
*/
public function applyProperty($plugin_id, UserInterface $retire_user, UserInterface $retain_user, array $settings = []) {
$this->propertyPluginManager
->createInstance($plugin_id)
->process($retire_user, $retain_user, $settings);
}
/**
* {@inheritdoc}
*/
public function getPropertyPlugins() {
$plugin_ids = [];
foreach ($this->propertyPluginManager
->getDefinitions() as $plugin_id => $definition) {
$plugin_ids[] = $plugin_id;
}
return $plugin_ids;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
UserMerger:: |
protected | property | Action plugin manager. | |
UserMerger:: |
protected | property | Property plugin manager. | |
UserMerger:: |
public | function |
Applies the action to take on the user account being retired. Overrides UserMergerInterface:: |
|
UserMerger:: |
public | function |
Applies a property plugin to a set of accounts being merged. Overrides UserMergerInterface:: |
|
UserMerger:: |
public | function |
Gets a list of property plugin ids. Overrides UserMergerInterface:: |
|
UserMerger:: |
public | function |
Merges two user accounts. Overrides UserMergerInterface:: |
|
UserMerger:: |
public | function | Creates a user merger object. |