public function Revision::processEntity in Entity Share 8.3
Method called on STAGE_PROCESS_ENTITY.
If the plugin reacts to this stage.
Parameters
\Drupal\entity_share_client\RuntimeImportContext $runtime_import_context: The import context.
\Drupal\Core\Entity\ContentEntityInterface $processed_entity: The entity being processed.
array $entity_json_data: The entity JSON data.
Overrides ImportProcessorPluginBase::processEntity
File
- modules/
entity_share_client/ src/ Plugin/ EntityShareClient/ Processor/ Revision.php, line 94
Class
- Revision
- Create new revision for already created entities.
Namespace
Drupal\entity_share_client\Plugin\EntityShareClient\ProcessorCode
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(),
]));
}
}
}