Add a path variant system

Created on 26 November 2024, 26 days ago

Motivation

A requirement for experience builder outlined in ✨ Support adding additional routes for view modes other than 'full' Active is to have alternative canonical routes, where the routes are tied to configured view modes. The view modes would have configured paths, just like entities have a canonical path.

This issue exists to add a system for custom paths for alternate canonical routes.

View mode variants will be added in ✨ Support adding additional routes for view modes other than 'full' Active .

Contrib impact

  • Pathauto would be able to hook in with their own patterns.
  • Subpathauto would be able to register patterns in a performant way. E.g [entity:title]/customPath. (Computation of "subpaths" can happen beforehand, instead of at runtime)

I suggest this issue as a predecessor to ✨ Support adding additional routes for view modes other than 'full' Active , since I dont think it makes sense to tie internals of Path/PathAlias, especialy PathAlias entity, PathItem, PathFieldItemList, and PathWidget, with concepts like Entity View Modes. Especially since there should be contrib hookability. And be able to integrate with Core concepts like Entity Form Modes in the future.

Doing all this before ✨ Support adding additional routes for view modes other than 'full' Active allows its view mode integration to stay very small. I've created a MR in that issue that stacks on the MR here @ !REPLACE.

What this will not do?

Proposed resolution

Implement appropriate events to allow core and contrib to specify variants, and variant and internal paths.

Remaining tasks

Architectural and technical review
Add coverage for new systems
Test passing

User interface changes

A path fieldset is displayed PER variant.

Introduced terminology

  • Path variants

API changes

  • API surface additions just for variants.
  • New events dispatched
  • Existing path_alias.repository and its interface had a change to \Drupal\path_alias\AliasRepository::lookupBySystemPath method signature to allow optional variant lookups.

Data model changes

  • Database schema changed: Introduces a `variant` field (database column) to PathAlias. All existing pathalias have a NULL value, which equates to the "default" variant.
  • No config schema changes.

Release notes snippet

✨ Feature request
Status

Active

Version

11.0 πŸ”₯

Component

path.module

Created by

πŸ‡¦πŸ‡ΊAustralia dpi Perth, Australia

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

Merge Requests

Comments & Activities

  • Issue created by @dpi
  • Merge request !10345Path Variants β†’ (Open) created by dpi
  • Pipeline finished with Failed
    26 days ago
    Total: 148s
    #350535
  • Pipeline finished with Failed
    26 days ago
    Total: 553s
    #350552
  • πŸ‡¦πŸ‡ΊAustralia dpi Perth, Australia

    Im currently looking for architectural review, particularly from XB stakeholders, before tests are added.

    PHPStan and linting has been much improved, to a level above our formal required minimum level 1.

    The change to make path fields multi cardinality impacts serialization and JSONAPI especially, and their related tests.

    Some tests are updated, a bunch of random test failures still come up recently..

    Some of @larowlans work from ✨ Support adding additional routes for view modes other than 'full' Active contained changes to path UI. I couldnt tell which direction he was going as the wip commit was a bit messed up:

    So I went with a details/fieldsets per path variant instead of a major change to make the existing one fieldset to contain a tabular layout. Something to discuss further anyway. Or even improve in a follow up.

    Theres something up with the path.module postupdate from πŸ› Improve performance for path_alias queries in a workspace Active . Its not updating the index properly with the variant hook_update at the same time. So I've moved it to a hook_update just for the purposes of getting tests going. I'd appreciate advice there.

  • πŸ‡¦πŸ‡ΊAustralia dpi Perth, Australia
  • πŸ‡¦πŸ‡ΊAustralia dpi Perth, Australia
  • πŸ‡¦πŸ‡ΊAustralia dpi Perth, Australia

    From the contrib issue @ ✨ Add path/pathauto integration Active , we might be able to do link templates + associated toUrl bits here.

  • πŸ‡¦πŸ‡ΊAustralia dpi Perth, Australia
  • πŸ‡¦πŸ‡ΊAustralia dpi Perth, Australia
  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10
  • πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

    Would we need safeguards to avoid someone adding "edit" as a view mode, which would lead to two possible route matches for "node/$nid/edit"?

Production build 0.71.5 2024