diff --git a/src/Plugin/Field/FieldFormatter/EntityReferenceRevisionsFormatterBase.php b/src/Plugin/Field/FieldFormatter/EntityReferenceRevisionsFormatterBase.php index 1535682..f0c660b 100644 --- a/src/Plugin/Field/FieldFormatter/EntityReferenceRevisionsFormatterBase.php +++ b/src/Plugin/Field/FieldFormatter/EntityReferenceRevisionsFormatterBase.php @@ -24,9 +24,6 @@ abstract class EntityReferenceRevisionsFormatterBase extends EntityReferenceForm $item->entity = $item->getReferencedEntity(); $item->_loaded = TRUE; } - elseif ($item->hasNewEntity()) { - $item->_loaded = TRUE; - } } } } diff --git a/src/Plugin/Field/FieldType/EntityReferenceRevisionsItem.php b/src/Plugin/Field/FieldType/EntityReferenceRevisionsItem.php index 76c042d..ff3d349 100644 --- a/src/Plugin/Field/FieldType/EntityReferenceRevisionsItem.php +++ b/src/Plugin/Field/FieldType/EntityReferenceRevisionsItem.php @@ -40,8 +40,10 @@ class EntityReferenceRevisionsItem extends EntityReferenceItem implements Option /** * Reference to the entity pointed to by this field. + * + * @var Drupal\Core\Entity\EntityInterface */ - protected $entity_cache; + protected $entityCache = NULL; /** * {@inheritdoc} @@ -213,18 +215,18 @@ class EntityReferenceRevisionsItem extends EntityReferenceItem implements Option if (isset($this->entity)) { return $this->entity; } - elseif (isset($this->entity_cache)) { - return $this->entity_cache; + elseif (NULL !== $this->entityCache) { + return $this->entityCache; } elseif (isset($this->target_id)) { $storage = \Drupal::entityTypeManager()->getStorage($this->getSetting('target_type')); // By default always load the default revision, so caches get used. - $this->entity_cache = $storage->load($this->target_id); - if ($this->entity_cache !== NULL && $this->entity_cache->getRevisionId() != $this->revision_id) { + $this->entityCache = $storage->load($this->target_id); + if ($this->entityCache !== NULL && $this->entityCache->getRevisionId() != $this->revision_id) { // A non-default revision is a referenced, so load this one. - $this->entity_cache = $storage->loadRevision($this->revision_id); + $this->entityCache = $storage->loadRevision($this->revision_id); } - return $this->entity_cache; + return $this->entityCache; } }