Created
March 31, 2020 21:52
-
-
Save a-fro/1c9b5fcf778edcc49eb39dab292cbc0c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/Controller/ParagraphsPreviewController.php b/src/Controller/ParagraphsPreviewController.php | |
index 3fe50c4..924c75f 100644 | |
--- a/src/Controller/ParagraphsPreviewController.php | |
+++ b/src/Controller/ParagraphsPreviewController.php | |
@@ -176,6 +176,13 @@ class ParagraphsPreviewController extends ControllerBase { | |
// EntityViewBuilder::viewFieldItem(). | |
$elements = $parent_clone->{$parent_field_name}->view($parent_view_mode); | |
+ // When layout builder is enabled for an entity, viewBuilder->view_field() | |
+ // returns and empty array. Using default display options instead returns | |
+ // the render array we were expecting so we can preview it. | |
+ if (empty($elements)) { | |
+ $elements = $parent_clone->{$parent_field_name}->view(); | |
+ } | |
+ | |
// Extract the part of the render array we need. | |
$output = isset($elements[0]) ? $elements[0] : []; | |
if (isset($elements['#access'])) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment