diff --git a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php index 672fc073e2..7257e17aee 100644 --- a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php +++ b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php @@ -6,6 +6,7 @@ use Drupal\Core\Config\Entity\ConfigEntityInterface; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Entity\Display\EntityDisplayInterface; +use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Provides a common base class for entity view and form displays. @@ -570,4 +571,25 @@ protected function getLogger() { return \Drupal::logger('system'); } + /** + * {@inheritdoc} + */ + public function label() { + $target_entity_type = $this->entityTypeManager()->getDefinition($this->getTargetEntityTypeId()); + if ($target_entity_type->getBundleEntityType() !== NULL) { + $bundle_info = $this->entityTypeBundleInfo()->getBundleInfo($this->getTargetEntityTypeId()); + $bundle_label = $bundle_info[$this->getTargetBundle()]['label']; + return new TranslatableMarkup('@label: @bundle (display mode: @mode)', [ + '@bundle' => $bundle_label, + '@label' => $target_entity_type->getLabel(), + '@mode' => $this->getMode(), + ]); + } + // No bundles. + return new TranslatableMarkup('@label (display mode: @mode)', [ + '@label' => $target_entity_type->getLabel(), + '@mode' => $this->getMode(), + ]); + } + } diff --git a/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php b/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php index 8f3b022899..14ee471c9d 100644 --- a/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php +++ b/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php @@ -341,18 +341,6 @@ protected function getContextsForEntity(FieldableEntityInterface $entity) { ] + $this->contextRepository()->getAvailableContexts(); } - /** - * {@inheritdoc} - * - * @todo Move this upstream in https://www.drupal.org/node/2939931. - */ - public function label() { - $bundle_info = \Drupal::service('entity_type.bundle.info')->getBundleInfo($this->getTargetEntityTypeId()); - $bundle_label = $bundle_info[$this->getTargetBundle()]['label']; - $target_entity_type = $this->entityTypeManager()->getDefinition($this->getTargetEntityTypeId()); - return new TranslatableMarkup('@bundle @label', ['@bundle' => $bundle_label, '@label' => $target_entity_type->getPluralLabel()]); - } - /** * {@inheritdoc} */