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
Vocabulary entity has hard-coded routes in taxonomy.routing.yml
We can make use of a route provider that was added later on and remove the hard-coding
Additionally, the link to add-form in the annotations of the Vocabulary entity points to the term add form, rather than the vocabulary add form.
Proposed resolution
Use a route provider
Remaining tasks
Patch
Get tests green
Profit
User interface changes
None
API changes
None
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#16 | taxonomy-route_provider-2919891-16.patch | 7.53 KB | darvanen |
Comments
Comment #2
larowlanComment #3
darvanenComment #4
darvanenYAML file translated to RouteProvider
Comment #6
tstoecklerThanks for getting the ball rolling on this effort again! Adding parent issue.
Also looked at the actual patch. Really nice work! I do have a number of comments, though, most of them are just minor cleanup, though.
It's unfortunate that this route is in the "taxonomy_vocabulary" namespace as, conceptually, I think it matches more closely to a term collection route. However, I am not sure we can properly generate a collection route which depends on the bundle anyway, so I think it makes most sense to do exactly what you did.
The generic title being used here is "Add @lowercase_entity_label".
It is unfortunate that the label of the Vocabulary entity type is (incorrectly, in my opinion) "Taxonomy vocabulary", so the corresponding lowercase label would be "taxonomy vocabulary". So I think it's correct to override the title here. Alternatively we could change the label to just "Vocabulary" but I guess that could be considered a break of backwards-compatibility. So I think this is exactly right. (Also note #2507235: EntityType::getLowercaseLabel() breaks translation)
Again, the generic label is determined by the collection label in the annotation. I could see an argument that "a collection of vocabularies" is synonymous with "Taxonomy" (if not in the generic meaning of those words, maybe that is true at least in Drupal). If so, we could simply add a collection label to vocabularies and drop this override. Not 100% sure, though.
For extra credit we could use
$entity_type->getAdminPermission()
here to maybe this just a tad less hardcoded.Copy-paste error.
I think - even though, as far as I can tell, this is not strictly required for this patch - it makes sense to include this as part of this patch. But why not also add an "edit" form operation, as well, in that case?
This makes a lot of sense!
Nice bugfix!
The double-permissions are not covered by the auto-generated route, so for now we will have to override this. I have also hit this a bunch of times and have thought about whether we need some sort of "collection permission" in addition to the admin permission, but for now let's just do an override.
This is currently not covered by the route provider. Not sure, whether it is actually needed to port this, though. Maybe we can get some before/after screenshots of the taxonomy edit page title and then get some usability feedback on whether this change is acceptable (I would argue it's even an improvement) Please also include some HTML in the vocabulary label, as the current edit page label is quite weird in that it outputs the vocabulary label as HTML. With the generic label the page title just becomes "Edit %label".
Again, this is now changed to "Delete %label" with the generic route, but I would argue that this is actually a nice little improvement. I do think we need confirmation by the usability team, though.
Comment #7
larowlanCould we update the issue summary to include the bug in the link template
Thanks again @Darvanen - great work
Comment #8
darvanenComment #9
darvanenThanks for the detailed review @tstoeckler!
I set out to translate the YML file as closely as I could and clean up a few things that I found (like that bug). So while I think it's great to take this opportunity to identify areas for improvement, perhaps it's best to turn those into new issues? I'll take guidance on that of course because this is my first time working on core.
I've fixed the three failed tests. I hope.
Comment #10
tstoecklerThanks for the fixes!
WTF?! I would totally have bet money on the fact that that doesn't work and is totally broken...
...but I see that you've just taken that over from the YAML file. Nice catch! (Still looks quite bizarre, due to the spaces in the string.)
So I really have nothing to complain about with your patch, it looks perfect. Just one note about your answers in #9:
So what I was thinking was to add
label_collection = @Translation("Taxonomy")
to the entity type annotation which would alleviate the need to override the title here. That is definitely not a BC-break, the question is rather whether that is actually the correct "collection label". Having thought about this a bit, I think the answer is yes. However, I think it's totally fine to leave the patch as is, and consider doing that in a separate issue.On a more general note, and somewhat in reply to your points 10. and 11.: When working on other route providers for core before, I have experienced core committers not being to fond of having all these overrides in the route providers. That is why I mentioned that it might make sense to introduce small UI changes (potentially even improvements) so that the route provider becomes a little less heavy.
But let's find out what the committers say about this. For me, the patch looks good to go as is. If the test bot doesn't complain, I will mark this RTBC.
Comment #11
tstoecklerComment #12
catchYes in a minor release we can make small string changes, so if the defaults provided by the route provider are fine (or an improvement), then I think we should drop the overrides here - this will slowly make entity type management in the UI more consistent as well. CNR for that - we might need screenshots for those UI changes though just to see what's going on.
Comment #13
tstoecklerOK, so concrete suggestions:
label_collection
and remove the_title
override for the collection route. (No UI change)This will leave the permission override for the collection route as the only override. The route provider will then still contain the two additional vocabulary-specific routes.
@catch, does that sound acceptable?
Comment #14
larowlan+1 for removing special casing.
Comment #15
darvanenFindings:
Before:
After:
The test is expecting "Tags" at the end of the breadcrumb and receives "Edit Tags"
So my question is should I update the test?
Comment #16
darvanenAssuming the answer is affirmative, here's the patch and interdiff including the change to the test (because otherwise there will definitely be a failure). Let's see what the testbot makes of it.
Comment #17
tstoecklerYes, the answer is in fact affirmative ;-)
I did not realize that both
VocabularyForm
andEntityConfirmFormBase
use#title
to set the page title, therefore the changes are less invasive than I thought. The screenshots in #15.3 show the only visible change: the breadcrumb. Note that this is not a double-escape bug, but the label of the vocabulary is literally"<em>Fluffy</em> Stuff"
. In current HEAD, the label is actually put as HTML into the breadcrumb.As far as I can tell, the issue summary was updated above already, so going back to RTBC.
Edit: Well, of course trying to show HTML in a textarea that accepts HTML as input is not really smart. Next try.
Comment #19
catchCommitted/pushed to 8.5.x, thanks!
Comment #20
tstoecklerThanks for the quick turnaround @catch! The way this issue has gone makes me hopeful that we can we make some more progress on route providers.
Thinking about this more lead me to open #2924408: Deprecate TaxonomyController::vocabularyTitle().
Comment #21
darvanen