class PropertyComment in User Merge 2.x
Class PropertyComment.
@UserMergeProperty( id = "property_comment", name = @Translation("Comment data"), description = @Translation("Reassign comments associated with the retired user."), review = "", provider = "comment" ) @package Drupal\usermerge\Plugin\UserMerge\Property
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\usermerge\Plugin\UserMerge\Property\UserMergePropertyBase implements UserMergePropertyPluginInterface
- class \Drupal\usermerge\Plugin\UserMerge\Property\PropertyComment
- class \Drupal\usermerge\Plugin\UserMerge\Property\UserMergePropertyBase implements UserMergePropertyPluginInterface
Expanded class hierarchy of PropertyComment
File
- src/
Plugin/ UserMerge/ Property/ PropertyComment.php, line 23
Namespace
Drupal\usermerge\Plugin\UserMerge\PropertyView source
class PropertyComment extends UserMergePropertyBase {
/**
* {@inheritDoc}
*/
public function process(UserInterface $retired, UserInterface $retained, array $settings = []) : void {
try {
$comment_storage = $this->entityTypeManager
->getStorage('comment');
} catch (PluginNotFoundException|InvalidPluginDefinitionException $e) {
throw new UserMergeException('Storage for comment entity has not been found.');
}
$comment_ids = $comment_storage
->getQuery()
->condition('uid', $retired
->id())
->execute();
$comments = $comment_storage
->loadMultiple($comment_ids);
try {
/** @var \Drupal\comment\CommentInterface $comment */
foreach ($comments as $comment) {
$comment
->setOwnerId($retained
->id());
$comment
->save();
}
} catch (EntityStorageException $e) {
throw new UserMergeException('An error occurred during comment reassignment.');
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
2 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PropertyComment:: |
public | function |
Process merge on selected property. Overrides UserMergePropertyPluginInterface:: |
|
UserMergePropertyBase:: |
protected | property | Entity type manager. | |
UserMergePropertyBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
3 |
UserMergePropertyBase:: |
public | function |
Return the name of the property plugin. Overrides UserMergePropertyPluginInterface:: |
|
UserMergePropertyBase:: |
public | function |
Get the review form if it is provided by the plugin. Overrides UserMergePropertyPluginInterface:: |
|
UserMergePropertyBase:: |
public | function |
PropertyComment constructor. Overrides PluginBase:: |
3 |