Require label and category properties for layout plugins

Created on 24 July 2024, about 2 months ago
Updated 26 July 2024, about 1 month ago

Problem/Motivation

Per How to register layouts πŸ› Add missing 'label' key to navigation.layouts.yml Active :

The 'label' and 'category' keys are required.

This came up in πŸ› Add missing category to Drupal\layout_builder\Plugin\Layout\BlankLayout and let modules and themes alter the list of layouts RTBC and πŸ› Add missing 'label' key to navigation.layouts.yml Active . There was a thought to make the two keys required in the annotation to attribute conversion in πŸ“Œ Convert Layout plugin discovery to attributes Active , per #2 πŸ“Œ Convert Layout plugin discovery to attributes Active and #17 πŸ“Œ Convert Layout plugin discovery to attributes Active :

I think we should consider a BC layer where we add a label for unlabelled layouts and trigger a deprecation.

, but then it was kicked back to be done in πŸ› Add missing category to Drupal\layout_builder\Plugin\Layout\BlankLayout and let modules and themes alter the list of layouts RTBC , and finally decided to do a separate follow up, which is this issue.

The most direct way to address would be to make the Layout attribute label and category properties required, but some considerations:

  • Are there uses cases where layout plugin derivers provide label or category?
  • CategorizingPluginManagerTrait::processDefinitionCategory() provides a default category of the provider module name or machine name when the plugin definition is an array. Layout plugin definitions are objects, not arrays, but something similar can be implemented so that the same default category is assigned to the plugin definition when the plugin manager processes the definition

Steps to reproduce

Proposed resolution

  • Add label to any current existing core layouts without one
  • Trigger deprecation on any layouts that do not have a label
  • In LayoutPluginManger:: processDefinition(), add a default category of the plugin provider (see CategorizingPluginManagerTrait::processDefinitionCategory())
  • Investigate whether there are use cases for derivers providing plugin labels

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
PluginΒ  β†’

Last updated about 13 hours ago

Created by

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024