Change record status: 
Project: 
Introduced in branch: 
11.3.x
Introduced in version: 
11.3.0
Description: 

If an entity type is overridden using a hook_entity_type_alter to use a different class, it was possible to use statically the entity type or the overridden version:

OriginalClass::loadMultiple(); // Ok.
OverrideClass::loadMultiple(); // Ok.

But if another module overrides again the entity type class, then the static calls of the first override would not work:

Original::loadMultiple(); // Ok.
Override::loadMultiple(); // Error.
AnotherOverride::loadMultiple(); // Ok.

Now it is possible to override an entity type class multiple times without issue in the entity type manager finding the correct class to load.

A new getDecoratedClasses method had been added in case your code needs to check for an entity type class.

Before:

$entity_type->getOriginalClass() == $class_name

After:

in_array($class_name, $entity_type->getDecoratedClasses(), TRUE)

The new method allows to support any number of overrides.

Impacts: 
Module developers