Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Except for aggregator_feed
, node
and user
, all content entity types are still declaring their routes manually instead of utilizing the default route provider we have in core now.
Proposed resolution
Use a route provider for all core content entity types, specifically:
action
#2956385: Use route provider for action entitiesblock_content
comment
menu_link_content
shortcut
taxonomy_term
Remaining tasks
User interface changes
None.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#42 | 2723615-42.patch | 25.91 KB | longwave |
#27 | 2723615-26.patch | 26.49 KB | robpowell |
Comments
Comment #2
tstoecklerComment #3
tstoecklerHere we go.
Leaving menu links out for now, because they do something interesting with bundles. Will open a separate issue for that.
Comment #5
tstoecklerRebased local branch with 8.2.x
Comment #7
tstoecklerOpened #2760653: Use an entity route provider for taxonomy terms for the menu links, see the IS there for why.
Comment #8
tstoecklerComment #9
tstoecklerSo this is also postponed on #2751835: Entity::urlRouteParameters() is broken for add-page and add-form link templates because taxonomy terms also have the same weird code that nodes have that prints out all entity links in the head.
Let's see if a combined patch is green.
Comment #10
tstoecklerComment #11
tstoecklerComment #12
dawehnerReally great work!
Is there any way to properly unset a value?
Comment #13
tstoecklerThere's no dedicated method. What we could do is:
That was a bit too verbose for my taste, so I went with the slightly less correct but more readable version. I don't feel strongly, though. If you think the above would be better, I can do that.
Comment #14
tstoecklerImplemented #13.
I am also splitting out the taxonomy changes out of this issue. That way this no longer needs to be postponed. I am moving those over to #2760653: Use an entity route provider for taxonomy terms which was originally about menu link, but I am merging menu links back in here. So the attached patch is the one in #5 plus the one in #5 over there (plus the attached interdiff per #13).
Comment #15
tstoecklerMerging #2760653: Use an entity route provider for taxonomy terms back in here, not that that's no longer postponed.
Comment #17
dawehnerThat is certainly super nice work!
Should we mark this method as deprecated as well?
I'm wondering whether we should maybe copy the route definition or so?
Comment #18
tstoecklerThanks for the review, much appreciated!
Re #17:
in
\Drupal\block_content\Entity\BlockContentHtmlRouteProvider::getAddFormRoute()
.Comment #19
tstoecklerComment #22
tstoecklerComment #24
phenaproximaThis definitely needs a re-roll.
Comment #25
robpowellI am rerolling for SprintWeekend2018
Comment #26
robpowellComment #27
robpowellwhoops
Comment #28
phenaproximaThanks, @robpowell and @tstoeckler! This is a pretty straightforward patch, and a very nice improvement to the entity system.
Is there a way to mark these routes as deprecated?
Should be trigger a deprecation notice in the method itself?
Ditto here.
We should probably trigger a deprecation notice here.
Why is this deviating from the generic entity.FOOBAR.add_form pattern?
We should fire a deprecation notice here.
Inaccurate doc comment.
Again, why is this deviating from the entity.TYPE.add_form pattern?
Should fire a deprecation notice here.
Needs a doc comment update.
Comment #30
andypostAdded #2956385: Use route provider for action entities to summary
Comment #31
andypostIs there policy about deprecation of route names?
Comment #33
AaronMcHaleAccording to the issue summary:
node
anduser
could benefit from using or extending theDefaultHtmlRouteProvider
class, as currently they do provide their own Route Provider classes but those classes don't extendDefaultHtmlRouteProvider
resulting in unnecessary code and YAML entries, this issue seems like a good place to also resolve that.For clarity
aggregator_feed
does provide a Route Provider class, but it does extendDefaultHtmlRouteProvider
so nothing needs done there.Comment #34
AaronMcHaleFound #2723579: [PP-1] NodeRouteProvider should extend DefaultHtmlRouteProvider, last activity over there seems older than on this issue though, we can either leave that one open and fix over there, or close that one and fix over here, any preferences?
Comment #35
tstoecklerRe #34: These sets of issues have been very contentious in the past because they sometimes involve minor behavior changes and/or arguable API changes, so I would prefer to scope them as small as possible. So let's leave that issue open just for nodes.
Comment #36
AaronMcHale@tstoeckler yeah fair enough, it'll also mean this issue will likely land in Core quicker if the scope remains as it is.
Comment #37
andypostComment #42
longwaveRerolled for 9.3.x, #28 not addressed yet.
Comment #46
andypostneeds separate issue
needs own issue
the same
Comment #47
andypostProbably it should be postponed on #3159210: Support route aliasing (Symfony 5.4) and allow deprecating the route name to provide BC for route names
Comment #48
longwaveAgree with #47, let's postpone until we can provide BC.
Comment #50
larowlanBlock content module has support for deprecating routes, see
\Drupal\block_content\Controller\BlockContentController::blockContentTypeRedirect
this can be active again I think