Needs work
Project:
Drupal core
Version:
main
Component:
routing system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
7 Apr 2014 at 23:40 UTC
Updated:
18 Mar 2026 at 14:05 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
tim.plunkettComment #2
tim.plunkettComment #3
pwolanin commentedLooks good, though I'd make the $title param optional
$title = ''perhaps? If it's missing maybe put in the link or generate the URL?Comment #5
tim.plunkettWe don't have any usages for that, and I don't see why they couldn't just pass in '' themselves. Generating the URL is not a bad idea either, but honestly either of those could be added later without an API change.
Comment #6
amateescu commentedHow about introducing a Link value object instead of muddying the waters in the Url class? That would be similar to the distinction we had previously with
l()andurl()(which made a lot of sense, imo).Comment #7
pwolanin commented@amateescu - this came out of my concern that the current function doesn't currently return a valid render array, and the link element is the only thing that makes sense in terms of the context where it's used.
Comment #8
tim.plunkett#6, I'm not against that, but it'd be helpful to see a PoC, because as I envision it, it'd be rather ugly.
If we choose to not do either what I have in the patch or what #6 says, we can just s/toRenderArray/toRenderArrayFragment/ and be done with it.
Comment #9
amateescu commentedI think renaming the method to
toRenderArrayFragment()would be the non-controversial change at this point. This method could be used (potentially) for the autocompete form element, something like:That's why I'd prefer to not limit its functionality to a link element.
Comment #10
tim.plunkettAgreed that it's non-controversial and make sense. I like the look of the code in #5, but I agree its a weird coupling of links and URLs.
Comment #11
andriyun commentedComment #12
denismosolov commentedHello, folks!
I've just renamed the method. I hope I understood the task correct.
Thanks
Comment #13
andriyun commentedComment #14
tvn commentedComment #15
pwolanin commentedHow about just toRenderfragment()?
Comment #16
cilefen commentedComment #17
hottaco commentedComment #18
hotpizzas commentedRerolled patch.
Encountered simple conflicts in the following files:
core/modules/user/src/Form/UserCancelForm.php
core/modules/node/src/Form/NodeDeleteForm.php
core/modules/entity_reference/src/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php
core/lib/Drupal/Core/Form/ConfirmFormHelper.php
No longer exists in head:
core/modules/comment/lib/Drupal/comment/Form/DeleteForm.php
Comment #19
mrjmd commentedComment #21
tim.plunkettThanks for rerolling!
That's not really in scope, is it?
And if so, let's make it
$title = ''in the method signature.Whoops!
What's the reason for this change?
Comment #22
cilefen commented@tim.plunkett I addressed your comments. It looks like we really need title='' in the signature because there are some existing usages that don't include $title. Also I tried to return ConfirmFormHelper to the original intent in #5.
Comment #23
tim.plunkettMy question was why we're introducing #title in an issue that is only about renaming the toRenderArray method.
Comment #25
cilefen commentedComment #27
cilefen commentedComment #29
cilefen commentedWow, core moves fast!
Comment #31
tim.plunkettOkay, let's just get this in. It will be useful for the conversions we need to do.
Comment #32
webchickI'm showing it to eff and neither of us understand why, now that this *is* returning a full render array with a #type => link, it makes sense to rename the thing to RenderArrayFragment. Seems like this is now returning a complete render array, no?
In addition, the word "Fragment" is overloaded. Not only because of HTML Page fragments, but also because of URL fragments, and this is on the Url class. :)
If we get a re-roll of this without the rename, this should be safe for anytime post-beta. But setting to needs review first because I don't quite parse peter's concerns in #7.
Comment #33
webchickIf, on the other hand, we decide to not have the Url class making assumptions about #type being link, then effulgentsia suggests maybe toRenderArrayProperties().
Comment #34
pwolanin commentedI'm fine with it being #type => link, but in that case I agree that we shouldn't change the method name. The whole motivation was since it didn't include a #type
Comment #35
pwolanin commentedComment #36
pwolanin commentedchange the method name back.
Comment #37
cilefen commentedThis satisfies the requirements of #32 and #34 and it is green.
Comment #38
dawehnerI don't think this is a sane idea, if you want to add it, just use += later or earlier. We are basically treating easy to use vs. sanity. Why should a url care about titles. If you want that, move this code to the link class
Same thing as before, a URL is not a link
Comment #39
amateescu commentedRe: #38: Yup. Also #6, #9 and #10 above.
Comment #40
pwolanin commentedIn the face of a lack of consensus - I sought a final decision from alexpott. This is the decision:
The method should be renamed to
renderArrayProperties()It will otherwise stay functionally the same and not provide a #type or #title.
Comment #41
pwolanin commentedComment #42
cilefen commentedLet's see how well phpstorm handles this.
Comment #43
pwolanin commentedsimple method name fix - looks good
Comment #45
tim.plunkettRerolled.
Comment #47
tim.plunkettInterestingly enough, #2347465: Convert all instances of #type link/links to convert to use routes removes all but 3 usages of toRenderArray (since
'#url' => $thisis used in its place)Comment #48
cilefen commentedRerolled.
Comment #49
pwolanin commented@tim.plunkett - should we remove the method after that goes in instead?
Comment #50
dawehnerI really kinda feel that this issue is pointless.
Comment #53
dawehnerLet's do that in 9, its not worth to do that at all anymore in D8.
Comment #54
kgoel commentedComment #55
catchWe could do it in a late minor release of 8.1.x with a deprecation, if we're really going to make the full change in 9.x.
Comment #61
dawehnerComment #73
smustgrave commentedThank you for creating this issue to improve Drupal.
We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.
Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.
Thanks!
Keeping in NW as I had bandwidth to review and still seems valid.