Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / modules / layout_builder / src / Plugin / Block / ExtraFieldBlock.php
index ddb7f01fd9bfa3047c57499b49e81486e1bfa316..6b991037687d4d9c9ae76afadad3a74a5e8aa602 100644 (file)
@@ -130,13 +130,22 @@ class ExtraFieldBlock extends BlockBase implements ContextAwarePluginInterface,
         // render array. If the hook is invoked the placeholder will be
         // replaced.
         // @see ::replaceFieldPlaceholder()
-        '#markup' => new TranslatableMarkup('Placeholder for the "@field" field', ['@field' => $extra_fields['display'][$this->fieldName]['label']]),
+        '#markup' => $this->getPreviewFallbackString(),
       ];
     }
     CacheableMetadata::createFromObject($this)->applyTo($build);
     return $build;
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public function getPreviewFallbackString() {
+    $entity = $this->getEntity();
+    $extra_fields = $this->entityFieldManager->getExtraFields($entity->getEntityTypeId(), $entity->bundle());
+    return new TranslatableMarkup('Placeholder for the "@field" field', ['@field' => $extra_fields['display'][$this->fieldName]['label']]);
+  }
+
   /**
    * Replaces all placeholders for a given field.
    *