- Issue created by @godotislate
While converting \Drupal\Core\Display\Annotation\DisplayVariant
and \Drupal\Core\Display\Annotation\PageDisplayVariant
plugins 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.
Active
11.0 π₯
Last updated