Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process the definition via layout plugin manager, so the new plugin get fully populated. #289

Open
wants to merge 1 commit into
base: 8.x-1.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion modules/ui_patterns_layouts/ui_patterns_layouts.module
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}
}

Expand Down