Deprecate uri_callback in routes for entities

Created on 11 February 2016, almost 9 years ago
Updated 31 March 2023, over 1 year ago

API page: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21...

The documentation on this page related to routing appears to have some errors in it. I can tell you that it's wrong, but I'm not quite sure what it should be yet. If someone can help me figure out what it should say I'm happy to update things.

Right now, the documentation says this:

For content entities that are displayed on their own pages, the annotation will refer to a 'uri_callback' function, which takes an object of the entity interface you have defined as its parameter, and returns routing information for the entity page; see node_uri() for an example. You will also need to add a corresponding route to your module's routing.yml file; see the entity.node.canonical route in node.routing.yml for an example, and see Entity routes below for some notes.

Optionally, instead of defining routes, routes can be auto generated by providing a route handler. See Entity routes. Otherwise, define routes and links for the various URLs associated with the entity. These go into the 'links' annotation, with the link type as the key, and the path of this link template as the value. The corresponding route requires the following route name: "entity.$entity_type_id.$link_template_type". See Entity routes below for some routing notes. Typical link types are:

The node.routing.yml does not have an entry for the entity.node.canonical route, and the annotation for \Drupal\node\Entity\Node does not have a "uri_callback" key. I believe this is related to ๐Ÿ“Œ [meta] convert โ€˜uri_callbackโ€™ entities param to EntityInterface::uri() method Active . The entity.node.canonical route is not dynamically generated, as are most other similar styles routes. It does look forum, and comment entities have not been updated to the new pattern yet.

The newer, and from what I can tell recommended, pattern is the 2nd one described in the documentation above. Providing a route handler.

Is the use of "uri_callback" in an annotation deprecated? Is it removed and we're just figuring out how to deal with comment/forum entities still? We should either remove that block, or update it so that it references a module like comment that actually makes use of the system being described.

๐Ÿ“Œ Task
Status

Needs work

Version

10.1 โœจ

Component
Entityย  โ†’

Last updated about 13 hours ago

  • Maintained by
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom @catch
  • ๐Ÿ‡จ๐Ÿ‡ญSwitzerland @berdir
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany @hchonov
Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States eojthebrave Minneapolis, MN

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024