Updated: Comment #N
Problem/Motivation
ConfirmFormInterface::getCancelRoute() should only return \Drupal\Core\Url objects, but it can return either that or arrays right now, and is only documented to return arrays.
Proposed resolution
Switch getCancelRoute() to always return objects, and remove the array handling code from ConfirmFormHelper.
This is consistent with the changes to $form_state['redirect_route'] and $entity->urlInfo().
Remaining tasks
N/A
User interface changes
N/A
API changes
getCancelRoute() can no longer return arrays, only \Drupal\Core\Url objects
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | confirm-getcancelroute-2226871-14.patch | 60.12 KB | tim.plunkett |
Comments
Comment #1
tim.plunkettComment #3
tim.plunkett1: confirm-form-2226871-1.patch queued for re-testing.
Comment #5
dawehnerIs there a reason to not actually use @covers ?
This is NOT a valid route name. HTML also does not make sense on an URL object.
Comment #6
tim.plunkett1) Because this was written before we were using @covers.
2) Copy/paste. Fixed throughout
Comment #7
tim.plunkettComment #8
tim.plunkettLet's just repurpose this, no sense in breaking it up.
Comment #10
tim.plunkettComment #11
sunHm. I wanted to RTBC this, but then I noticed that a positive/successful form submission uses
getCancelRoute()as the redirect target...It basically re-purposes
getCancelRoute()to not only be the route for the "Cancel" link, but also the route for a successful operation? That seems a little bit weird, no? Or is that documented somewhere?Would it make sense to simply add a new
getRedirectRoute()method to the base class that - by default - internally calls intogetCancelRoute(), but which essentially ensures that the two (vastly different) conditions are properly covered in the public API?Comment #12
tim.plunkettJudging by the ones I converted, I'd say that only 2/3 of the classes use the same route for cancel and submit.
It's just a matter of convenience, I don't think that its harmful, and I definitely don't think it's worth adding Yet Another Method for.
Comment #13
tim.plunkettI should also note, almost none of these classes have parent::submitForm(), so it would not be as easy as putting it into the base class. I think this is fine as is, and is a pattern that exists in HEAD.
Comment #14
tim.plunkettRerolled.
Comment #15
tim.plunkett14: confirm-getcancelroute-2226871-14.patch queued for re-testing.
Comment #16
sunOh sorry, I missed that this is not a default/automation - just some classes are internally calling their own method to… not duplicate code (?), I guess.
My comment in #11 would only make sense if there was an automated default route, in which case it would be weird if the redirect route after successful submission would default to the cancel route.
Comment #17
webchickDown with ArrayPIs! :P
Committed and pushed to 8.x. Thanks!