From 0a38c37b1461a82d233bb14ffb871c40c66b0077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20L=C3=B3pez?= Date: Thu, 5 Mar 2020 18:26:51 +0100 Subject: [PATCH] Process the definition via layout plugin manager, so the new plugin get fully populated. --- .../ui_patterns_layouts/ui_patterns_layouts.module | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/ui_patterns_layouts/ui_patterns_layouts.module b/modules/ui_patterns_layouts/ui_patterns_layouts.module index 9aa74e55..038df9cb 100644 --- a/modules/ui_patterns_layouts/ui_patterns_layouts.module +++ b/modules/ui_patterns_layouts/ui_patterns_layouts.module @@ -18,6 +18,9 @@ use Drupal\field_layout\Display\EntityDisplayWithLayoutInterface; function ui_patterns_layouts_layout_alter(&$definitions) { /** @var \Drupal\ui_patterns\Definition\PatternDefinition[] $pattern_definitions */ + /** @var \Drupal\Core\Layout\LayoutPluginManager $layout_plugin_manager */ + $layout_plugin_manager = \Drupal::service('plugin.manager.core.layout'); + // @todo: Use layout deriver instead. // @link https://github.com/nuvoleweb/ui_patterns/issues/94 foreach (UiPatterns::getPatternDefinitions() as $pattern_definition) { @@ -33,7 +36,15 @@ function ui_patterns_layouts_layout_alter(&$definitions) { foreach ($pattern_definition->getFields() as $field) { $definition['regions'][$field->getName()]['label'] = $field->getLabel(); } - $definitions['pattern_' . $pattern_definition->id()] = new LayoutDefinition($definition); + + // Process the definition via layout plugin manager, so the new plugin get + // fully populated. + $layout_definition = new LayoutDefinition($definition); + $plugin_id = 'pattern_' . $pattern_definition->id(); + + $layout_plugin_manager->processDefinition($layout_definition, $plugin_id); + + $definitions[$plugin_id] = $layout_definition; } }