Pull merge.
[yaffs-website] / web / core / lib / Drupal / Core / Entity / Entity / EntityViewDisplay.php
index 74b15b65f4754ebff62267a668027cc4ba52c9e6..6783522ac9baca6262bd5f3c57a383c042c19c0d 100644 (file)
@@ -8,7 +8,8 @@ use Drupal\Core\Entity\EntityDisplayPluginCollection;
 use Drupal\Core\Entity\EntityStorageInterface;
 use Drupal\Core\Entity\FieldableEntityInterface;
 use Drupal\Core\Entity\EntityDisplayBase;
-use Drupal\Core\TypedData\TranslatableInterface;
+use Drupal\Core\Render\Element;
+use Drupal\Core\TypedData\TranslatableInterface as TranslatableDataInterface;
 
 /**
  * Configuration entity that contains display options for all components of a
@@ -21,6 +22,9 @@ use Drupal\Core\TypedData\TranslatableInterface;
  *     "id" = "id",
  *     "status" = "status"
  *   },
+ *   handlers = {
+ *     "access" = "\Drupal\Core\Entity\Entity\Access\EntityViewDisplayAccessControlHandler",
+ *   },
  *   config_export = {
  *     "id",
  *     "targetEntityType",
@@ -198,7 +202,7 @@ class EntityViewDisplay extends EntityDisplayBase implements EntityViewDisplayIn
         'view_mode' => $this->originalMode,
         // No need to prepare, defaults have been merged in setComponent().
         'prepare' => FALSE,
-        'configuration' => $configuration
+        'configuration' => $configuration,
       ]);
     }
     else {
@@ -250,7 +254,7 @@ class EntityViewDisplay extends EntityDisplayBase implements EntityViewDisplayIn
           // those values using:
           // - the entity language if the entity is translatable,
           // - the current "content language" otherwise.
-          if ($entity instanceof TranslatableInterface && $entity->isTranslatable()) {
+          if ($entity instanceof TranslatableDataInterface && $entity->isTranslatable()) {
             $view_langcode = $entity->language()->getId();
           }
           else {
@@ -266,7 +270,7 @@ class EntityViewDisplay extends EntityDisplayBase implements EntityViewDisplayIn
     foreach ($entities as $id => $entity) {
       // Assign the configured weights.
       foreach ($this->getComponents() as $name => $options) {
-        if (isset($build_list[$id][$name])) {
+        if (isset($build_list[$id][$name]) && !Element::isEmpty($build_list[$id][$name])) {
           $build_list[$id][$name]['#weight'] = $options['weight'];
         }
       }
@@ -298,7 +302,7 @@ class EntityViewDisplay extends EntityDisplayBase implements EntityViewDisplayIn
     }
 
     return [
-      'formatters' => new EntityDisplayPluginCollection($this->pluginManager, $configurations)
+      'formatters' => new EntityDisplayPluginCollection($this->pluginManager, $configurations),
     ];
   }