Overview
Based on this discussion with Pierre and Wim
Indeed, I would not recommend to add this to your component definitions:
attributes: type: Drupal\Core\Template\Attribute name: Attributes title: AttributesBecause this prop is injected automatically by SDC anyway.
But most importantly, because using a PHP namespace as a prop type is not JSON Schema compliant. It is an SDC quirk, a Drupalism, we need to get rid off.
Related issue, kind of: #3457874: HTML attributes as Twig mappings instead of PHP objects
— @pdureau at #3468944-11: Update XB's `image` SDC to comply with best practices, and document those best practices
We can and should remove the attributes section of components, e.g.
https://git.drupalcode.org/project/experience_builder/-/blob/0.x/compone...
# @see \Drupal\Core\Template\ComponentsTwigExtension::mergeAdditionalRenderContext()
attributes:
type: Drupal\Core\Template\Attribute
name: Attributes
title: Attributes
Proposed resolution
Remove them.
User interface changes
Issue fork experience_builder-3470575
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
kristen polAdding credit.
Comment #6
omkar-pd commentedComment #7
wim leers+1 for theory
First: I'd love to see this simplified: it's very unfortunate that SDC's metadata is all JSON schema, except for this. Both the SDC subsystem and the XB module have to do a fair bit of special casing to make this work. For example, in XB:
… but in practice: not sure?
I'm not quite convinced yet. 😅
If this is such a bad practice, then why does every SDC in Drupal core have this?!
See:
core/profiles/demo_umami/themes/umami/components/branding/branding.component.ymlcore/profiles/demo_umami/themes/umami/components/banner/banner.component.yml(literally the only prop there!)core/themes/olivero/components/teaser/teaser.component.yml(literally the only prop there!)So: can you point to a place where this removal was discussed?
Comment #8
wim leers