Skip to content

Layout definitions from patterns lack id property #313

@nedjo

Description

@nedjo

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions