Closed (fixed)
Project:
Entity API
Version:
8.x-1.x-dev
Component:
Entity CRUD admin UI
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
22 Aug 2018 at 14:03 UTC
Updated:
2 Apr 2019 at 12:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
tstoecklerHere it is.
Comment #3
tstoecklerOh right: One thing that is weird is the current "Revisions" Task that automatically gets added to all entity types. It's kind of unfortunate to have two different methods of adding tasks to entities, but I guess it would be a BC-break to convert this to a local task provider because that would inherently make it opt-in.
I mean theoretically we could also add an appropriate local task provider in
hook_entity_type_build()for the revisions task, but not sure...Comment #4
tstoecklerComment #5
bojanz commentedLet's do this.
Comment #6
bojanz commentedMeant to post that in #2989556: Make EntityCollectionLocalActionProvider add a destination query parameter.
Regarding #3, could we just merge RevisionsOverviewDeriver into EntityLocalTask?
Comment #7
tstoecklerOK, so something like this? I think this would certainly be the cleanest solution. On the one hand people might not be happy about their Revisions tab disappearing, on the other hand, we can tell them "Hey, add these 3 lines to your annotation and you can delete *all* of your local tasks" so...
I renamed the provider, somehow I couldn't get that to show up properly in the interdiff.
Comment #9
tstoecklerOops, I'm not quite up-to-date, it seems ;-)
Comment #11
tstoecklerAnd I guess a bit trigger-happy today. Sorry for the noise.
Not sure what to do with the RevisionOverviewTest. Removing it for now, not sure what others think.
Comment #12
mjpa commentedFound this patch while trying to work out how to stop this module from enforcing the revisions local task... works fine for that bit :D
Comment #13
bojanz commentedI'm fine with the approach to the version-history, but I'm confused by the EntityLocalTask class.
It feels very unusual for a plugin class to hardcode every possible title
What's wrong with using t() in the DefaultEntityTasksProvider?
Another unusual thing is that we provide a local task for version-history, but we don't provide a route for it.
Comment #14
tstoecklerAs far as I know the local tasks are cached in a way that running the translation at build time would not result in the proper runtime translation being applied. I did not investigate this deeply, though, I just copied the pattern from what we do with route providers, where it is actually necessary to do this. Will test and investigate though, to see if we can avoid this.
Sorry, I don't understand. As far as I can tell the route is generated by
\Drupal\entity\Routing\RevisionRouteProvider::getRevisionHistoryRoute().Comment #15
morenstratI applied the patch, added the local_task_provider handler to my custom entity type and the local tasks appeared.
Comment #16
tstoecklerSo I looked into the translation thing and it is indeed not necessary because local tasks are cached by langcode. See
LocalTaskManager::__construct():So here's a simplified patch. The interdiff doesn't show the removed
EntityLocalTaskbecause I accidentally deleted that in PhpStorm.I will now go and look if I did that workaround for the local action thing unnecessarily, as well...
Leaving at RTBC, since it's basically just removed code, hope that's OK here.
Comment #17
tstoecklerAhem... #3028768: Remove unnecessary translation workaround in local action plugin
Comment #18
bojanz commentedRemoved an unused use statement from EntityLocalTaskTest and added a one-line note to the README about the new feature.
Thank you!
Followup: #3041435: Provide an automatic local task for the Duplicate operation.