X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Flib%2FDrupal%2FCore%2FEntity%2FEntityType.php;fp=web%2Fcore%2Flib%2FDrupal%2FCore%2FEntity%2FEntityType.php;h=28f5b4ed753e6d2be39c9f6bcb24ce1f41dad9ee;hp=9584ed3e26511dac2b420aa516f128d91d6fde20;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/web/core/lib/Drupal/Core/Entity/EntityType.php b/web/core/lib/Drupal/Core/Entity/EntityType.php index 9584ed3e2..28f5b4ed7 100644 --- a/web/core/lib/Drupal/Core/Entity/EntityType.php +++ b/web/core/lib/Drupal/Core/Entity/EntityType.php @@ -154,6 +154,13 @@ class EntityType extends PluginDefinition implements EntityTypeInterface { */ protected $data_table = NULL; + /** + * Indicates whether the entity data is internal. + * + * @var bool + */ + protected $internal = FALSE; + /** * Indicates whether entities of this type have multilingual support. * @@ -311,11 +318,16 @@ class EntityType extends PluginDefinition implements EntityTypeInterface { $this->checkStorageClass($this->handlers['storage']); } - // Automatically add the EntityChanged constraint if the entity type tracks - // the changed time. + // Automatically add the "EntityChanged" constraint if the entity type + // tracks the changed time. if ($this->entityClassImplements(EntityChangedInterface::class)) { $this->addConstraint('EntityChanged'); } + // Automatically add the "EntityUntranslatableFields" constraint if we have + // an entity type supporting translatable fields and pending revisions. + if ($this->entityClassImplements(ContentEntityInterface::class)) { + $this->addConstraint('EntityUntranslatableFields'); + } // Ensure a default list cache tag is set. if (empty($this->list_cache_tags)) { @@ -349,6 +361,13 @@ class EntityType extends PluginDefinition implements EntityTypeInterface { return $this; } + /** + * {@inheritdoc} + */ + public function isInternal() { + return $this->internal; + } + /** * {@inheritdoc} */ @@ -677,7 +696,15 @@ class EntityType extends PluginDefinition implements EntityTypeInterface { * {@inheritdoc} */ public function getBundleLabel() { - return (string) $this->bundle_label; + // If there is no bundle label defined, try to provide some sensible + // fallbacks. + if (!empty($this->bundle_label)) { + return (string) $this->bundle_label; + } + elseif ($bundle_entity_type_id = $this->getBundleEntityType()) { + return (string) \Drupal::entityTypeManager()->getDefinition($bundle_entity_type_id)->getLabel(); + } + return (string) new TranslatableMarkup('@type_label bundle', ['@type_label' => $this->getLabel()], [], $this->getStringTranslation()); } /**