Skip to content
Snippets Groups Projects

Issue #2949412: Nested paragraphs automatically publish, even if the parent is a draft

1 file
+ 15
2
Compare changes
  • Side-by-side
  • Inline
+ 15
2
@@ -124,8 +124,21 @@ class Paragraph extends ContentEntityBase implements ParagraphInterface {
if (!isset($this->get('parent_type')->value) || !isset($this->get('parent_id')->value)) {
return NULL;
}
$parent = \Drupal::entityTypeManager()->getStorage($this->get('parent_type')->value)->load($this->get('parent_id')->value);
$parentFieldName = $this->parent_field_name->value;
// Look up the paragraph's parent by the revision.
$entity_type_manager = \Drupal::entityTypeManager();
$target_entity_storage = $entity_type_manager->getStorage($this->get('parent_type')->value);
// Query parent entity type revisions that contain the paragraph at it's
// given version id.
$revision_ids = $target_entity_storage
->getQuery()
->allRevisions()
->condition($parentFieldName . '.target_revision_id', $this->getLoadedRevisionId())
->condition($parentFieldName . '.target_id', $this->id())
->execute();
$parent = \Drupal::entityTypeManager()->getStorage($this->get('parent_type')->value)->loadRevision(array_key_first($revision_ids));
// Return current translation of parent entity, if it exists.
if ($parent != NULL && ($parent instanceof TranslatableInterface) && $parent->hasTranslation($this->language()->getId())) {
Loading