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

Layout definitions from patterns lack id property #313

Open
nedjo opened this issue Nov 22, 2020 · 0 comments · May be fixed by #314
Open

Layout definitions from patterns lack id property #313

nedjo opened this issue Nov 22, 2020 · 0 comments · May be fixed by #314

Comments

@nedjo
Copy link

nedjo commented Nov 22, 2020

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

  • Add one or more UI patterns to a site.
  • Install the UI Patterns Layouts submodule.
  • Run code like the following:
    $definitions = \Drupal::service('plugin.manager.core.layout')->getGroupedDefinitions();
    
    foreach ($definitions['Patterns'] as $definition) {
      // Examine the return value of $definition->id().
    }

Result: the value is empty.

Proposed fix

Pass an id value to the LayoutDefinition constructor.

nedjo pushed a commit to nedjo/ui_patterns that referenced this issue Nov 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant