Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 295445

EntityViewBuilder::getBuildDefaults doesn't respect the EntityInterface of the $entity parameter

$
0
0

Problem/Motivation

The EntityViewBuilder::getBuildDefaults has an $entity parameter that should respect the EntityInterface.

Yet in the getBuildDefaults() method there's a call on the $entity object to a method that's not on the EntityInterface:

$entity->isDefaultRevision();

isDefaultRevision() lives on the ContentEntityBase but EntityViewBuilder might be used by a ConfigEntityBase.

This may result in an error Error: Call to undefined method Drupal\my_module\Entity\MyConfigEntity::isDefaultRevision() in EntityViewBuilder.php on line 181

Proposed resolution

We should check if the entity is an instance of RevisionableInterface first:

$entity instanceof RevisionableInterface

Viewing all articles
Browse latest Browse all 295445

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>