Skip to content
Snippets Groups Projects
Commit f4528ccf authored by Justin Toupin's avatar Justin Toupin
Browse files

Removed getRegions() from LayoutParagraphsSection. Since sections do not have...

Removed getRegions() from LayoutParagraphsSection. Since sections do not have awareness of Layout Plugins and since components store the region they are associated with, sections have no real way of retrieving a complete list of regions. That functionality should be moved into the LayoutParagraphsService with the injected Layout Plugin Manager service.
parent 4d77e3e2
No related branches found
No related tags found
No related merge requests found
...@@ -35,17 +35,6 @@ class LayoutParagraphsSection extends LayoutParagraphsComponent implements Layou ...@@ -35,17 +35,6 @@ class LayoutParagraphsSection extends LayoutParagraphsComponent implements Layou
return $settings['layout']; return $settings['layout'];
} }
/**
* Get the regions associated with this layout paragraph.
*
* @return array
* An array of region names.
*/
public function getRegions() {
$settings = $this->getSettings();
return array_keys($settings['regions']);
}
/** /**
* Returns the layout plugin settings for the provided paragraph. * Returns the layout plugin settings for the provided paragraph.
* *
......
...@@ -59,19 +59,19 @@ class LayoutParagraphsService { ...@@ -59,19 +59,19 @@ class LayoutParagraphsService {
$section = new LayoutParagraphsSection($paragraph); $section = new LayoutParagraphsSection($paragraph);
$view_builder = $this->entityTypeManager->getViewBuilder('paragraph'); $view_builder = $this->entityTypeManager->getViewBuilder('paragraph');
$layout = $this
->layoutPluginManager
->createInstance($section->getLayoutId(), $section->getLayoutConfiguration());
// Map rendered paragraphs into their respective regions. // Map rendered paragraphs into their respective regions.
foreach ($section->getRegions() as $region) { $regions = $layout->getPluginDefinition()->getRegions();
foreach (array_keys($regions) as $region) {
$regions[$region] = array_map(function ($component) use ($view_builder, $view_mode) { $regions[$region] = array_map(function ($component) use ($view_builder, $view_mode) {
return $view_builder->view($component->getEntity(), $view_mode); return $view_builder->view($component->getEntity(), $view_mode);
}, $section->getComponentsForRegion($region)); }, $section->getComponentsForRegion($region));
} }
// Build the layout render array using the appropriate layout plugin. return $layout->build($regions);
$layout_plugin_instance = $this
->layoutPluginManager
->createInstance($section->getLayoutId(), $section->getLayoutConfiguration());
return $layout_plugin_instance->build($regions);
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment