Loading core/lib/Drupal/Core/Entity/EntityType.php +25 −5 Original line number Diff line number Diff line Loading @@ -66,6 +66,13 @@ class EntityType extends PluginDefinition implements EntityTypeInterface { */ protected $originalClass; /** * The list of the classes when overridden. * * @var class-string[] */ protected array $decoratedClasses = []; /** * An array of handlers. * Loading Loading @@ -385,7 +392,10 @@ public function get($property) { * {@inheritdoc} */ public function set($property, $value) { if (property_exists($this, $property)) { if ($property === 'class') { $this->setClass($value); } elseif (property_exists($this, $property)) { $this->{$property} = $value; } else { Loading Loading @@ -452,15 +462,25 @@ public function getOriginalClass() { return $this->originalClass ?: $this->class; } /** * {@inheritdoc} */ public function getDecoratedClasses(): array { return $this->decoratedClasses; } /** * {@inheritdoc} */ public function setClass($class) { if (!$this->originalClass && $this->class) { if ($this->class) { if (!$this->originalClass) { // If the original class is currently not set, set it to the current // class, assume that is the original class name. $this->originalClass = $this->class; } $this->decoratedClasses[] = $this->class; } return parent::setClass($class); } Loading core/lib/Drupal/Core/Entity/EntityTypeInterface.php +11 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,17 @@ public function set($property, $value); */ public function getOriginalClass(); /** * Gets the list of all the classes for this entity type. * * In case the class name was changed with setClass(), this will return * the list of all the changes. * * @return class-string[] * The list of classes. */ public function getDecoratedClasses(): array; /** * Gets an array of entity keys. * Loading core/lib/Drupal/Core/Entity/EntityTypeRepository.php +1 −1 Original line number Diff line number Diff line Loading @@ -77,7 +77,7 @@ public function getEntityTypeFromClass($class_name) { $entity_type_id = NULL; $definitions = $this->entityTypeManager->getDefinitions(); foreach ($definitions as $entity_type) { if ($entity_type->getOriginalClass() == $class_name || $entity_type->getClass() == $class_name) { if (in_array($class_name, $entity_type->getDecoratedClasses(), TRUE) || $entity_type->getClass() == $class_name) { $entity_type_id = $entity_type->id(); if ($same_class++) { throw new AmbiguousEntityClassException($class_name); Loading core/modules/layout_builder/tests/modules/layout_builder_override/layout_builder_override.info.yml 0 → 100644 +5 −0 Original line number Diff line number Diff line name: 'Layout Builder Override Test' type: module description: 'Test layout builder override.' package: Testing version: VERSION core/modules/layout_builder/tests/modules/layout_builder_override/src/Entity/EntityViewDisplay.php 0 → 100644 +14 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace Drupal\layout_builder_override\Entity; use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\Core\Entity\Entity\EntityViewDisplay as BaseEntityViewDisplay; /** * Stub class to evaluate the override. */ class EntityViewDisplay extends BaseEntityViewDisplay implements EntityViewDisplayInterface { } Loading
core/lib/Drupal/Core/Entity/EntityType.php +25 −5 Original line number Diff line number Diff line Loading @@ -66,6 +66,13 @@ class EntityType extends PluginDefinition implements EntityTypeInterface { */ protected $originalClass; /** * The list of the classes when overridden. * * @var class-string[] */ protected array $decoratedClasses = []; /** * An array of handlers. * Loading Loading @@ -385,7 +392,10 @@ public function get($property) { * {@inheritdoc} */ public function set($property, $value) { if (property_exists($this, $property)) { if ($property === 'class') { $this->setClass($value); } elseif (property_exists($this, $property)) { $this->{$property} = $value; } else { Loading Loading @@ -452,15 +462,25 @@ public function getOriginalClass() { return $this->originalClass ?: $this->class; } /** * {@inheritdoc} */ public function getDecoratedClasses(): array { return $this->decoratedClasses; } /** * {@inheritdoc} */ public function setClass($class) { if (!$this->originalClass && $this->class) { if ($this->class) { if (!$this->originalClass) { // If the original class is currently not set, set it to the current // class, assume that is the original class name. $this->originalClass = $this->class; } $this->decoratedClasses[] = $this->class; } return parent::setClass($class); } Loading
core/lib/Drupal/Core/Entity/EntityTypeInterface.php +11 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,17 @@ public function set($property, $value); */ public function getOriginalClass(); /** * Gets the list of all the classes for this entity type. * * In case the class name was changed with setClass(), this will return * the list of all the changes. * * @return class-string[] * The list of classes. */ public function getDecoratedClasses(): array; /** * Gets an array of entity keys. * Loading
core/lib/Drupal/Core/Entity/EntityTypeRepository.php +1 −1 Original line number Diff line number Diff line Loading @@ -77,7 +77,7 @@ public function getEntityTypeFromClass($class_name) { $entity_type_id = NULL; $definitions = $this->entityTypeManager->getDefinitions(); foreach ($definitions as $entity_type) { if ($entity_type->getOriginalClass() == $class_name || $entity_type->getClass() == $class_name) { if (in_array($class_name, $entity_type->getDecoratedClasses(), TRUE) || $entity_type->getClass() == $class_name) { $entity_type_id = $entity_type->id(); if ($same_class++) { throw new AmbiguousEntityClassException($class_name); Loading
core/modules/layout_builder/tests/modules/layout_builder_override/layout_builder_override.info.yml 0 → 100644 +5 −0 Original line number Diff line number Diff line name: 'Layout Builder Override Test' type: module description: 'Test layout builder override.' package: Testing version: VERSION
core/modules/layout_builder/tests/modules/layout_builder_override/src/Entity/EntityViewDisplay.php 0 → 100644 +14 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace Drupal\layout_builder_override\Entity; use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\Core\Entity\Entity\EntityViewDisplay as BaseEntityViewDisplay; /** * Stub class to evaluate the override. */ class EntityViewDisplay extends BaseEntityViewDisplay implements EntityViewDisplayInterface { }