Change the uri from 'internal:' to 'entity:'

Created on 7 May 2025, 2 months ago

Problem/Motivation

The description of the $uri parameter of Url:fromUri says:

For a link to an entity you may use entity:{entity_type}/{entity_id} URIs.
The internal: scheme should be avoided except when processing actual user input that may or may not correspond to a Drupal route.

In the project I'm doing, this change is useful because I have terms linked from menu items that were imported via migration and the process plugin LinkUri convert entity URIs to the entity scheme.
With this change, going into edit of the term I would correctly see the menu item in the section introduced by taxonomy_menu_ui.

As a "bonus", by applying the patch #2423093-70: Allow multiple target entity types in the 'entity_autocomplete' Form API element , when I edit the menu link, I can correctly see the label of the referenced taxonomy term (instead of seeing /taxonomy/term/[tid])

Proposed resolution

Change the string saved in the database:

  • from: internal:/taxonomy/term/[tid]
  • to: entity:taxonomy_term/[tid]

Remaining tasks

If the change is accepted it will be necessary to add a hook_update to update the values ​​currently present in the database

📌 Task
Status

Active

Version

3.0

Component

Code

Created by

🇮🇹Italy robertom

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

Comments & Activities

Production build 0.71.5 2024