class Revision in Entity Share 8.3
Create new revision for already created entities.
Plugin annotation
@ImportProcessor(
id = "revision",
label = @Translation("Revision"),
description = @Translation("Create new revision."),
stages = {
"process_entity" = 10,
},
locked = false,
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\entity_share_client\ImportProcessor\ImportProcessorPluginBase implements ContainerFactoryPluginInterface, ImportProcessorInterface
- class \Drupal\entity_share_client\Plugin\EntityShareClient\Processor\Revision implements PluginFormInterface
- class \Drupal\entity_share_client\ImportProcessor\ImportProcessorPluginBase implements ContainerFactoryPluginInterface, ImportProcessorInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of Revision
File
- modules/
entity_share_client/ src/ Plugin/ EntityShareClient/ Processor/ Revision.php, line 27
Namespace
Drupal\entity_share_client\Plugin\EntityShareClient\ProcessorView source
class Revision extends ImportProcessorPluginBase implements PluginFormInterface {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* The time service.
*
* @var \Drupal\Component\Datetime\TimeInterface
*/
protected $time;
/**
* The Entity import state information service.
*
* @var \Drupal\entity_share_client\Service\StateInformationInterface
*/
protected $stateInformation;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
$instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);
$instance->entityTypeManager = $container
->get('entity_type.manager');
$instance->time = $container
->get('datetime.time');
$instance->stateInformation = $container
->get('entity_share_client.state_information');
return $instance;
}
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return [
'enforce_new_revision' => TRUE,
'translation_affected' => FALSE,
] + parent::defaultConfiguration();
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form['enforce_new_revision'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Enforce new revision'),
'#description' => $this
->t('Enforces an entity to be saved as a new revision.'),
'#default_value' => $this->configuration['enforce_new_revision'],
];
$form['translation_affected'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Enforce translation affected'),
'#description' => $this
->t('Not checking this option may cause confusing revision UI when using the Diff module.'),
'#default_value' => $this->configuration['translation_affected'],
];
return $form;
}
/**
* {@inheritdoc}
*/
public function processEntity(RuntimeImportContext $runtime_import_context, ContentEntityInterface $processed_entity, array $entity_json_data) {
$import_status_entity = $this->stateInformation
->getImportStatusOfEntity($processed_entity);
if ($processed_entity
->getEntityType()
->isRevisionable() && $this->configuration['enforce_new_revision'] && $import_status_entity) {
$processed_entity
->setNewRevision();
if ($this->configuration['translation_affected']) {
$processed_entity
->setRevisionTranslationAffected(TRUE);
}
try {
$revision_metadata_keys = $processed_entity
->getEntityType()
->getRevisionMetadataKeys();
if (isset($revision_metadata_keys['revision_created'])) {
$processed_entity->{$revision_metadata_keys['revision_created']}->value = $this->time
->getRequestTime();
}
if (isset($revision_metadata_keys['revision_log_message'])) {
$processed_entity->{$revision_metadata_keys['revision_log_message']}->value = $this
->t('Auto created revision during Entity Share synchronization.');
}
} catch (\Exception $e) {
$this
->messenger()
->addError($this
->t('There was a problem: @message', [
'@message' => $e
->getMessage(),
]));
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
ImportProcessorInterface:: |
constant | Processing stage: is entity importable. | ||
ImportProcessorInterface:: |
constant | Processing stage: post entity save. | ||
ImportProcessorInterface:: |
constant | Processing stage: prepare entity data. | ||
ImportProcessorInterface:: |
constant | Processing stage: prepare importable entity data. | ||
ImportProcessorInterface:: |
constant | Processing stage: process entity. | ||
ImportProcessorPluginBase:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurableInterface:: |
|
ImportProcessorPluginBase:: |
public | function |
Returns the plugin's description. Overrides ImportProcessorInterface:: |
|
ImportProcessorPluginBase:: |
public | function |
Returns the weight for a specific processing stage. Overrides ImportProcessorInterface:: |
|
ImportProcessorPluginBase:: |
public | function |
Method called on STAGE_IS_ENTITY_IMPORTABLE. Overrides ImportProcessorInterface:: |
2 |
ImportProcessorPluginBase:: |
public | function |
Determines whether this processor should always be enabled. Overrides ImportProcessorInterface:: |
|
ImportProcessorPluginBase:: |
public | function |
Returns the label for use on the administration pages. Overrides ImportProcessorInterface:: |
|
ImportProcessorPluginBase:: |
public | function |
Method called on STAGE_POST_ENTITY_SAVE. Overrides ImportProcessorInterface:: |
1 |
ImportProcessorPluginBase:: |
public | function |
Method called on STAGE_PREPARE_ENTITY_DATA. Overrides ImportProcessorInterface:: |
|
ImportProcessorPluginBase:: |
public | function |
Method called on STAGE_PREPARE_IMPORTABLE_ENTITY_DATA. Overrides ImportProcessorInterface:: |
4 |
ImportProcessorPluginBase:: |
public | function |
Sets the configuration for this plugin instance. Overrides ConfigurableInterface:: |
|
ImportProcessorPluginBase:: |
public | function |
Sets the weight for a specific processing stage. Overrides ImportProcessorInterface:: |
|
ImportProcessorPluginBase:: |
public | function | Form submission handler. | |
ImportProcessorPluginBase:: |
public | function |
Checks whether this processor implements a particular stage. Overrides ImportProcessorInterface:: |
|
ImportProcessorPluginBase:: |
public | function | Form validation handler. | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
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:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PluginBase:: |
public | function | Constructs a \Drupal\Component\Plugin\PluginBase object. | 92 |
Revision:: |
protected | property | The entity type manager. | |
Revision:: |
protected | property | The Entity import state information service. | |
Revision:: |
protected | property | The time service. | |
Revision:: |
public | function |
Form constructor. Overrides PluginFormInterface:: |
|
Revision:: |
public static | function |
Creates an instance of the plugin. Overrides ImportProcessorPluginBase:: |
|
Revision:: |
public | function |
Gets default configuration for this plugin. Overrides ImportProcessorPluginBase:: |
|
Revision:: |
public | function |
Method called on STAGE_PROCESS_ENTITY. Overrides ImportProcessorPluginBase:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |