diff --git a/core/modules/comment/src/CommentLazyBuilders.php b/core/modules/comment/src/CommentLazyBuilders.php index b49a53309d..730c840897 100644 --- a/core/modules/comment/src/CommentLazyBuilders.php +++ b/core/modules/comment/src/CommentLazyBuilders.php @@ -163,7 +163,7 @@ public function renderLinks($comment_entity_id, $view_mode, $langcode, $is_in_pr */ protected function buildLinks(CommentInterface $entity, EntityInterface $commented_entity) { $links = []; - $status = $commented_entity->getFieldValue($entity->getFieldName(), 'status'); + $status = $commented_entity->get($entity->getFieldName())->status; if ($status == CommentItemInterface::OPEN) { if ($entity->access('delete')) { diff --git a/core/modules/comment/src/Entity/Comment.php b/core/modules/comment/src/Entity/Comment.php index d86070a864..821b30d0ba 100644 --- a/core/modules/comment/src/Entity/Comment.php +++ b/core/modules/comment/src/Entity/Comment.php @@ -82,7 +82,7 @@ class Comment extends ContentEntityBase implements CommentInterface { public function preSave(EntityStorageInterface $storage) { parent::preSave($storage); - if (is_null($this->getStatus())) { + if (is_null($this->get('status')->value)) { if (\Drupal::currentUser()->hasPermission('skip comment approval')) { $this->setPublished(); } @@ -352,25 +352,21 @@ public function getParentComment() { * {@inheritdoc} */ public function getCommentedEntity() { - if ($this->getCommentedEntityTypeId() && $entity_id = $this->getCommentedEntityId()) { - return $this->entityTypeManager() - ->getStorage($this->getCommentedEntityTypeId()) - ->load($entity_id); - } + return $this->get('entity_id')->entity; } /** * {@inheritdoc} */ public function getCommentedEntityId() { - return $this->getFieldValue('entity_id', 'target_id'); + return $this->get('entity_id')->target_id; } /** * {@inheritdoc} */ public function getCommentedEntityTypeId() { - return $this->getFieldValue('entity_type', 'value'); + return $this->get('entity_type')->value; } /** @@ -385,7 +381,7 @@ public function setFieldName($field_name) { * {@inheritdoc} */ public function getFieldName() { - return $this->getFieldValue('field_name', 'value'); + return $this->get('field_name')->value; } /** @@ -486,7 +482,7 @@ public function setCreatedTime($created) { * {@inheritdoc} */ public function getStatus() { - return $this->getFieldValue('status', 'value'); + return $this->get('status')->value; } /** @@ -534,7 +530,7 @@ public function getOwner() { * {@inheritdoc} */ public function getOwnerId() { - return $this->getFieldValue('uid', 'target_id'); + return $this->get('uid')->target_id; } /**