diff --git a/paragraphs.install b/paragraphs.install index 5a25270..183c1eb 100644 --- a/paragraphs.install +++ b/paragraphs.install @@ -244,9 +244,23 @@ function paragraphs_update_8014() { } /** - * Remove the uid and revision_uid fields. + * Remove the base field overrides for moderation_state field. */ function paragraphs_update_8015() { + $config_factory = \Drupal::configFactory(); + $names = $config_factory->listAll('core.base_field_override.paragraph.'); + foreach ($names as $name) { + $config = $config_factory->getEditable($name); + if ($config->get('field_name') === 'moderation_state') { + $config->delete(); + } + } +} + +/** + * Remove the uid and revision_uid fields. + */ +function paragraphs_update_8016() { $tables_fields = [ 'paragraphs_item_revision' => 'revision_uid', 'paragraphs_item_field_data' => 'uid', diff --git a/src/Entity/Paragraph.php b/src/Entity/Paragraph.php index 1145a93..6e01789 100644 --- a/src/Entity/Paragraph.php +++ b/src/Entity/Paragraph.php @@ -234,8 +234,10 @@ class Paragraph extends ContentEntityBase implements ParagraphInterface { * check the parent entity instead. */ public function getOwner() { - if ($this->getParentEntity()) { - return $this->getParentEntity()->get('uid')->entity; + $parent = $this->getParentEntity(); + + if ($parent) { + return $parent->get('uid')->entity; } return NULL; @@ -248,8 +250,10 @@ class Paragraph extends ContentEntityBase implements ParagraphInterface { * check the parent entity instead. */ public function getOwnerId() { - if ($this->getParentEntity()) { - return $this->getParentEntity()->get('uid')->target_id; + $parent = $this->getParentEntity(); + + if ($parent) { + return $parent->get('uid')->target_id; } return NULL; @@ -296,8 +300,10 @@ class Paragraph extends ContentEntityBase implements ParagraphInterface { * check the parent entity instead. */ public function getRevisionAuthor() { - if ($this->getParentEntity()) { - return $this->getParentEntity()->get('revision_uid')->entity; + $parent = $this->getParentEntity(); + + if ($parent) { + return $parent->get('revision_uid')->entity; } return NULL;