Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / lib / Drupal / Core / Entity / EntityType.php
index 9584ed3e26511dac2b420aa516f128d91d6fde20..28f5b4ed753e6d2be39c9f6bcb24ce1f41dad9ee 100644 (file)
@@ -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());
   }
 
   /**