Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / modules / layout_builder / src / EventSubscriber / BlockComponentRenderArray.php
index c2e3bfb188899606daad512542260c377b03d872..276e680b43382ab3b99231f152d0c2d451574f2b 100644 (file)
@@ -5,6 +5,8 @@ namespace Drupal\layout_builder\EventSubscriber;
 use Drupal\block_content\Access\RefinableDependentAccessInterface;
 use Drupal\Core\Access\AccessResult;
 use Drupal\Core\Block\BlockPluginInterface;
+use Drupal\Core\Render\Element;
+use Drupal\Core\Render\PreviewFallbackInterface;
 use Drupal\Core\Session\AccountInterface;
 use Drupal\layout_builder\Access\LayoutPreviewAccessAllowed;
 use Drupal\layout_builder\Event\SectionComponentBuildRenderArrayEvent;
@@ -98,6 +100,9 @@ class BlockComponentRenderArray implements EventSubscriberInterface {
         '#weight' => $event->getComponent()->getWeight(),
         'content' => $block->build(),
       ];
+      if ($event->inPreview() && Element::isEmpty($build['content']) && $block instanceof PreviewFallbackInterface) {
+        $build['content']['#markup'] = $block->getPreviewFallbackString();
+      }
       $event->setBuild($build);
     }
   }