API page: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Url.php/c...

When you look at the class docs for Url, it hardly tell you anything. Developers reading this should be told that Url objects should be created with one of the static createFromFoo() methods, and it should give a brief list of these.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim created an issue. See original summary.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

devoidfury’s picture

Added to the comment there to point developers towards those static methods, and added a See Also entry for EntityBase::toUrl.

devoidfury’s picture

Status: Active » Needs review
joachim’s picture

Status: Needs review » Needs work

Looks good, but method names in docs need the () to be made into links on the API site I think.

The @see to the entity method is a nice touch!

dhirendra.mishra’s picture

Assigned: Unassigned » dhirendra.mishra
dhirendra.mishra’s picture

Assigned: dhirendra.mishra » Unassigned
Status: Needs work » Needs review
FileSize
419 bytes
625 bytes
dhirendra.mishra’s picture

FileSize
778 bytes
633 bytes

Pls consider this one.

joachim’s picture

Status: Needs review » Reviewed & tested by the community

Looks good! Thanks!

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

xjm’s picture

Version: 9.1.x-dev » 8.8.x-dev
Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs followup
Related issues: +#2417459: Provide internal API for special schemes and thin public wrappers for user input and non-routed URLs

So I thought that I'd fixed this documentation gap, like... five years ago. Turns out, the improvements never got committed because they were tied up in an API addition: #2417459: Provide internal API for special schemes and thin public wrappers for user input and non-routed URLs

Here's the docblock that was being added there:

+++ b/core/lib/Drupal/Core/Url.php
@@ -18,11 +18,98 @@
+ *
+ * This class supports:
+ * - External URLs.
+ * - Internal URLs that correspond to routes handled by Drupal's routing system.
+ * - Base-relative and host-relative URLs not handled by Drupal.
+ * - URLs for user input.
+ * - URLs for entities.
+ *
+ * New URLs should generally be constructed using one of the static factory
+ * methods. See:
+ * - Url::fromRoute()
+ * - Url::fromRouteMatch()
+ * - Url::fromUri()
+ * - Url::fromUserInput()
+ * - Url::fromBaseRelativePath()
+ * - Url::fromHostRelativePath()

Can we verify that's all correct information still, and include whatever of it is accurate in the patch here? Edit: the fromBaseRelativePath() and fromHostRelativePath() methods don't exist in HEAD, but the rest presumably still do.

As a followup, we should perhaps create a "URL generation" API topic, or perhaps add to the routing topic and make it "Routing and URL generation".

As a docs improvement, this is eligible for backport to the production branch. Thanks!

  • xjm committed dbc74bb on 9.1.x
    Issue #3063694 by dhirendra.mishra, devoidfury, joachim: class docs for...
xjm’s picture

Err, so I apparently forgot that I'd committed this locally before pushing a different commit. Rather than reverting it, though, let's iterate on it based on #11. Usually I would either revert or ask for a new issue, but the current version is adding information that's better than the nothing that was there in HEAD... so let's continue to work on this in this issue on top of the previous commit. Thanks!

  • xjm committed f309338 on 9.0.x
    Issue #3063694 by dhirendra.mishra, devoidfury, joachim: class docs for...

  • xjm committed 6b27860 on 8.9.x
    Issue #3063694 by dhirendra.mishra, devoidfury, joachim: class docs for...

  • xjm committed 3c7019f on 8.8.x
    Issue #3063694 by dhirendra.mishra, devoidfury, joachim: class docs for...
xjm’s picture

Might as well make the branches consistent for less confusion while I'm at it.

Swapnil_Kotwal’s picture

I have applied the patch. Kindly review the patch

rajandro’s picture

Status: Needs work » Needs review

Set to NR to trigger the test.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev
quietone’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Novice, -Needs followup +Bug Smash Initiative

I created two followups, one for the question in #11 #3269790: Improve class doc of core/lib/Drupal/Core/Url.php and the other is the followup requested in #11, #3269789: Add URL generation API topic. I made one for the question so that it can be handled on it's own, without code changes. It just keeps things simple.

That is everything to do here.

dww’s picture

Status: Reviewed & tested by the community » Fixed

From my reading of the issue history, the original fix was already committed and pushed. The necessary follow-ups now exist (thanks @quietone!). So I believe this is safe to call "fixed".

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.