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.
Updated: Comment #N
Problem/Motivation
#2153891: Add a Url value object added the new value object, but Entity is still passing around an array.
Proposed resolution
Switch the return signature.
Remaining tasks
N/A
User interface changes
N/A
API changes
Entity::urlInfo() now returns \Drupal\Core\Url
Comment | File | Size | Author |
---|---|---|---|
#20 | entity-url-2215961-20.patch | 65.08 KB | tim.plunkett |
#20 | interdiff.txt | 2.25 KB | tim.plunkett |
Comments
Comment #1
tim.plunkettComment #4
tim.plunkett1: entity-url-2215961-1.patch queued for re-testing.
Comment #6
BerdirThis makes the login work for me...
Comment #8
tim.plunkettThanks @Berdir! I could install and login just fine without that, no idea why.
That led me to a bunch of fixes.
Comment #10
tim.plunkettWhoops, missed one when picture was renamed.
Comment #11
dawehnerOH and the *** tag.
This is awesome!
Are we sue that 'redirect_route' is available all the time?
Are we sure $form_state['redirect_route'] always exists?
Comment #12
aspilicious CreditAttribution: aspilicious commentedI'm not a huge fan of fetching/changing/putting. I prefer methods on the object.
For example:
Or does that mess with the options because it gets added in the other direction?
Comment #13
tim.plunkettThere are cases where a mergeOptions would be nice, like in comment.module. But yes, in this case we're merging the opposite direction...
Comment #14
dawehner.
Comment #15
tim.plunkettWell https://drupal.org/node/2221879 hasn't been finished yet, we can clean that up and publish it when this goes in.
Comment #16
tim.plunkettComment #18
tim.plunkettDoh forgot to rebase
Comment #19
sunI wanted to RTBC this... I know this is a bit nitpicky, but...
In other words,
UnexpectedValueException
is supposed to be used within a chain of function calls when an argument (or return value) suddenly is not of an expected data type.For example,
DirectoryIterator::__construct()
:I first wanted to suggest
InvalidArgumentException
, but that's not completely right either — valid arguments depend on the particular domain object for which URL info is retrieved.Based on that,
DomainException
apparently comes closest:The example in the user comment essentially is a simplified code logic example of what we're doing here?
Comment #20
tim.plunkettI don't think any of those are exactly what we want.
So why not write our own!
Also opened #2228505: Clean up Entity exception classes to clean up the other exception classes.
Comment #21
sunRTBC on the assumption that testbot agrees. :)
Comment #22
tim.plunkettThere's a lot of changes here, but mostly just the same ones over and over.
Here are some highlights:
Comment #23
webchickOverall this looks fine to me, apart from:
:( Going from \Drupal::l() to \Drupal::linkGenerator()->generateFromUrl() is not nice DX. :(
But Tim pointed out that this code is now doing something different from what l() does internally, although we could open an issue to either switch l()'s behaviour wholesale from ->generate() to ->generateFromUrl() or introduce some new helper function (like Drupal::lurl()...lol :P)
I asked Tim about the change notice, since there's no draft here. He said that the draft notice in https://drupal.org/node/2221879 needs a bit of love, and also needs updating based on this change, so he plans to do both post-commit.
Ok, then. Committed and pushed to 8.x. Thanks!
Comment #25
tim.plunkettUpdated https://drupal.org/node/2221879, needs review
Comment #26
tim.plunkettComment #27
jessebeach CreditAttribution: jessebeach commentedPublished the change notice. Removed 'Needs change record' tag.