Overview

While working on #3469610: Prepare for multiple component types: prefix Component config entity IDs with `sdc` the use of + to separate parts of the config entity ID is still jarring.

Core uses dots freely, for example field.field.node.page.body or core.entity_form_display.media.audio.media_library and ConfigEntityStorage says

 * - ID: A string denoting the entity ID within the entity type namespace; e.g.,
 *   'article'. Entity IDs may contain dots/periods. The entire remaining string
 *   after the config_prefix in a config name forms the entity ID. Additional or
 *   custom suffixes are not possible.

When this was first proposed in #3444417: "Developer-created components": mark which SDCs should be exposed in XB the concern was that SDC IDs, which form part of the config entity name, can also contain dots - but I don't think this matters. For SDCs the format is now sdc+provider+name but with dots that is still fine: sdc.provider.my.dotted.sdc - we can just explode on the first two dots only to extract the name.

Proposed resolution

Replace + with . in component config entity IDs.

User interface changes

None

Command icon 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

longwave created an issue. See original summary.

wim leers’s picture

This sure would make Component config entity IDs feel less "alien" to experienced Drupal developers.

I'm +1 to giving this a try! 👍

longwave’s picture

Status: Active » Postponed

Find and replace did not take long so I just did it while #3469610: Prepare for multiple component types: prefix Component config entity IDs with `sdc` was fresh in my mind, but postponing as that needs to land first.

longwave’s picture

I also spotted that the regex currently disallows dotted SDC names and we have test coverage for this too:

'INVALID: period separated' => ['period.separated+period.separated]', FALSE],

If these are valid, we can deal with them in a followup.

wim leers’s picture

wim leers’s picture

Title: Replace plus with dot in component config entity IDs » Replace plus with dot in Component config entity IDs
Issue tags: +DX (Developer Experience)
longwave’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll

Rebased onto 0.x.

longwave’s picture

Assigned: Unassigned » wim leers
wim leers’s picture

Status: Needs review » Reviewed & tested by the community
Related issues: +#3465228: Twig disallows dashes in variable names, so SDC should disallow it in prop names and slots

I literally can't find the reason documented in #3444417: "Developer-created components": mark which SDCs should be exposed in XB nor in any Slack history.

To the best of my knowledge, we picked + as the separator because . might be a valid character in the name of an SDC.

But now I think allowing a period in the SDC plugin ID (for example foo.bar.component.yml to define a foo.bar SDC) is simply an oversight.
Since #3444417, I learned of other gaps in SDC's ComponentPluginManager, such as happily accepting SDC props names containing dashes, even though Twig does not allow dashes in variable names, and hence SDC allows for props names that are impossible to use in Twig! 🙈 See #3465228: Twig disallows dashes in variable names, so SDC should disallow it in prop names and slots.

This undeniably looks more familiar/less alien to Drupal developers. So, even though I'd like @f.mazeikis to sign off on this, I think this is a clear improvement towards making XB look more familiar/less alien to the rest of the Drupal community.

  • wim leers committed ea0beedc on 0.x authored by longwave
    Issue #3480193 by longwave, wim leers: Replace plus with dot in...
wim leers’s picture

Assigned: wim leers » Unassigned
Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.