Consolidate layout DisplayVariant, PageDisplayVariant plugin types

Created on 18 March 2024, 9 months ago

Problem/Motivation

While converting \Drupal\Core\Display\Annotation\DisplayVariant and \Drupal\Core\Display\Annotation\PageDisplayVariantplugins to use attributes in πŸ“Œ Convert Layout DisplayVariant, PageDisplayVariant discovery to attributes Needs review , some questions came up about documentation and usage of these plugin types, and what differentiates DisplayVariant and PageDisplayVariant.

Questions from the MR for πŸ“Œ Convert Layout DisplayVariant, PageDisplayVariant discovery to attributes Needs review : https://git.drupalcode.org/project/drupal/-/merge_requests/6818#note_281083

Somewhat unrelated to this change, but I'm a bit confused about what this one does exactly.
The attribute/annotation classes are solely used for discovery, and they're not persisted beyoned that. get() is called on them and then they're converted to an array/plugin definition object.
So it should make zero difference whether you use PageDisplayVariant or DisplayVariant.
The EntityType annotation/attribute classes are different in that they have different default values for a few properties.

Having not dug deep into the history, the difference is opaque to me as well. In the docblock for the Drupal\Component\Annotation\Plugin\DisplayVariant, there is this line:

 * @todo: Revise description when/if Displays are added to core:
 *   https://www.drupal.org/node/2292733

that was removed from the attribute docblock because of a suggestion from code review. It's not quite clear what was supposed to be result from that issue.
Also, the only instance of a DisplayVariant plugin is in a test class. Maybe there should be a follow-up issue about investigating usage of DisplayVariant vs PageDisplayVariant, and whether there even needs to be the two classes?

This issue is to investigate whether there needs to be two different plugin types, and if so, document the different use cases/needs. Otherwise, consolidate into one plugin type.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Active

Version

11.0 πŸ”₯

Component
BaseΒ  β†’

Last updated 1 day ago

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024