Skip to content
Snippets Groups Projects

2988382: Based on #39, add support for default_revision and keep_untranslatable_fields

1 file
+ 10
0
Compare changes
  • Side-by-side
  • Inline
@@ -8,6 +8,9 @@
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
use Drupal\Core\Entity\FieldableEntityInterface;
use Drupal\Core\Entity\RevisionableInterface;
use Drupal\Core\Entity\RevisionableStorageInterface;
use Drupal\Core\Entity\RevisionLogInterface;
use Drupal\Core\Field\FieldTypePluginManagerInterface;
use Drupal\Core\Session\AccountSwitcherInterface;
use Drupal\Core\TypedData\TranslatableInterface;
@@ -332,6 +335,13 @@ protected function updateEntity(EntityInterface $entity, Row $row) {
$entity->$field_name = NULL;
}
if (!empty($this->configuration['new_revision']) && $entity instanceof RevisionableInterface && $this->storage instanceof RevisionableStorageInterface) {
if ($entity instanceof RevisionLogInterface) {
$entity->setRevisionCreationTime(\Drupal::time()->getRequestTime());
}
$entity = $this->storage->createRevision($entity, $this->configuration['default_revision'] ?? TRUE, $this->configuration['keep_untranslatable_fields'] ?? NULL);
}
$this->setRollbackAction($row->getIdMap(), $rollback_action);
// We might have a different (translated) entity, so return it.
Loading