Problem/Motivation
So when defining a local action, you may specify a class to dynamically set some properties. A common use case is to slap on a 'destination' query parameter so people are redirected to the page the action was on after performing the action itself.
The menu_ui module already provides a class that does exactly that: \Drupal\menu_ui\Plugin\Menu\LocalAction\MenuLinkAdd. Why don't we generalize this class to core to something like: Drupal\Core\Menu\LocalActionWithDestination?
That way, all modules can use it without having to rely on menu_ui being enabled or having to duplicate the code.
Steps to reproduce
Not applicable.
Proposed resolution
Remaining tasks
Confirm the changes referred to at https://git.drupalcode.org/project/drupal/-/merge_requests/10366#note_41...
User interface changes
None.
Introduced terminology
None.
API changes
None.
Data model changes
None.
Release notes snippet
None.
| Comment | File | Size | Author |
|---|
Issue fork drupal-2762131
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 2762131-generalize-menulinkadd
changes, plain diff MR !10366
Comments
Comment #2
kristiaanvandeneyndeLet's see what testbot thinks of it. Should be a pretty straightforward patch and has BC.
Comment #3
kristiaanvandeneyndeHmm, looks like PhpStorm missed this whitespace.
Comment #4
bojanz commentedThe patch and the idea make sense. Committable in its current shape.
The old class didn't have a test, does a new one need it?
Comment #5
kristiaanvandeneyndeThanks for the review, bojanz!
As I mentioned on IRC, what's happening here is:
So all of the functionality is already being tested on a more granular/topical scale. I would love to write a test for this, although I fear it would simply replicate that which is already being tested.
Comment #6
dawehnerNitpick: whitespace :P
Well some form of kernel test or so would be great I guess. Something which ensures that the test fails in case this class is broken in some way.
Comment #7
dawehnerOh yeah in general I totally agree that this class makes 100% sense. Nice addition
Comment #13
psf_ commentedWork fine in D8.6.1
Comment #14
kristiaanvandeneyndeRerolling and seeing what testbot thinks of it nowadays
Comment #15
kristiaanvandeneyndeI can imagine it needs the deprecation handling mentioned here https://www.drupal.org/core/deprecation#how-class
Comment #17
kristiaanvandeneyndeTestbot hiccup. Setting back to RTBC but still on the fence re deprecation handling.
Comment #18
larowlanshould we be using \Drupal\Core\Routing\RedirectDestination::getAsArray here?
we need a trigger_error here as per our policy https://www.drupal.org/core/deprecation#how-class
we also need a deprecation test to ensure we have the error
Also #6 asked for a test, but I don't see them yet.
This is a great DX feature, thanks for working on it!
Comment #20
askibinski commentedRelated: #1344902: Provide an optional destination parameter for local actions
Comment #23
solimanharkas commented...attached wrong patch, will upload the right one shortly! sorry!
Comment #25
mohit_aghera commented- Fix the comments mentioned in #18
- Add test cases.
I noticed that the deprecation method for plugin is somewhat different as per the doc. I've updated it.
Comment #26
mohit_aghera commentedComment #27
mohit_aghera commentedFixing phpcs and other deprecation coding standard issues.
Comment #29
vsujeetkumar commentedFixing fail test.
Comment #31
idebr commentedNeeds work per #18.1
Comment #32
ravi.shankar commentedAddressed comment #31.
Comment #36
smustgrave commentedThis issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.
Maybe it's just me but if changing the class name couldn't that break existing sites?
If so we would need a different approach, maybe we deprecate the old
If not still think this could use a change record.
Comment #40
tstoecklerI don't understand, that's exactly what the patch does.
Added a draft change notice and converted to merge request.
Comment #41
tstoecklerThere was an issue in #32 in how
getAsArray()was used, that is fixed now and, thus, the tests are green again. Good to go from my point of view.Comment #42
kristiaanvandeneyndeDon't agree with #18.1, but other than that changes look good minus some tiny things. Left notes. Thanks for converting this @tstoeckler!
Comment #43
tstoecklerThanks for the review, fixed all the things now (hopefully).
Comment #44
kristiaanvandeneyndeLGTM now. As I said before, I don't think we need \Drupal\Core\Routing\RedirectDestination::getAsArray() here because AFAIAC it doesn't make sense in this context.
I saw one seemingly random test failure, so running that one again. Can RTBC if that one goes green.
Comment #45
kristiaanvandeneyndeAll green now.
Saving credit for Tobias, might remove some credit for broken patches but asking internally first.
Comment #46
kristiaanvandeneyndeComment #47
quietone commentedRead the IS, comments, the MR and the Change record. For the MR, a change was requested by larowlan, which has not happened. It is explained in the comments in the MR but that should have another check, it is at https://git.drupalcode.org/project/drupal/-/merge_requests/10366#note_41.... The other was the change record which I edited to focus on the impact and what sites need to do. I put the 'what is changed' at the top, followed by the action sites may need to take. and removed bits explaining how the deprecation is done.
I also updated credit.
Comment #49
oily commentedFilled out the issue summary template.
Comment #50
oily commentedAdded one code comment/ recommendation to the MR.
Comment #51
kristiaanvandeneyndeAdded to the discussion regarding the wording of a test case, but don't think that warrants removing RTBC. A committer an choose between the current docs and the ones suggested on commit.
Comment #53
alexpottCommitted b2205af and pushed to 11.x. Thanks!