nuvoleweb / ui_patterns

[NOTE] Development has moved to https://drupal.org/project/ui_patterns
https://drupal.org/project/ui_patterns
GNU General Public License v2.0
85 stars 56 forks source link

Layout definitions from patterns lack id property #313

Open nedjo opened 3 years ago

nedjo commented 3 years ago

Bug description

Layouts are defined for patterns in the UI Patterns Layouts submodule's hook_layout_alter() implementation.

The $definition passed to LayoutDefinition constructor lacks an id property. Because of this, the resulting definition has an empty id. What is expected instead is that the id will be the same as the key used when creating the layout, which is in the form 'pattern_' . $pattern_id where $pattern_id is the ID of the pattern.

This bug is causing incompatibility with certain other modules that use the layout definition ID value. One example is the Styleguide module, which derives a styleguide entry for each layout using the following code:

          $layoutInstance = $this->layoutPluginManager->createInstance($definition->id());

Currently attempting to view a styleguide on a site with layouts provided by UI Patterns Layouts produces the following fatal error:

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "" plugin does not exist.

Steps to reproduce

Result: the value is empty.

Proposed fix

Pass an id value to the LayoutDefinition constructor.