Pull merge.
[yaffs-website] / web / core / modules / layout_builder / src / Plugin / Block / FieldBlock.php
index bb8ed11797cf04f4314f36d1d7868a4eb193677a..88e608f6f465d8a2e62da64b251cb227136db0e7 100644 (file)
@@ -17,7 +17,6 @@ use Drupal\Core\Field\FormatterPluginManager;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
 use Drupal\Core\Plugin\ContextAwarePluginInterface;
-use Drupal\Core\Render\Element;
 use Drupal\Core\Session\AccountInterface;
 use Drupal\Core\StringTranslation\TranslatableMarkup;
 use Psr\Log\LoggerInterface;
@@ -160,13 +159,17 @@ class FieldBlock extends BlockBase implements ContextAwarePluginInterface, Conta
       $build = [];
       $this->logger->warning('The field "%field" failed to render with the error of "%error".', ['%field' => $this->fieldName, '%error' => $e->getMessage()]);
     }
-    if (!empty($entity->in_preview) && !Element::getVisibleChildren($build)) {
-      $build['content']['#markup'] = new TranslatableMarkup('Placeholder for the "@field" field', ['@field' => $this->getFieldDefinition()->getLabel()]);
-    }
     CacheableMetadata::createFromObject($this)->applyTo($build);
     return $build;
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public function getPreviewFallbackString() {
+    return new TranslatableMarkup('Placeholder for the "@field" field', ['@field' => $this->getFieldDefinition()->getLabel()]);
+  }
+
   /**
    * {@inheritdoc}
    */