Problem/Motivation

The routing system has three special route names: <front>, <current>, and <none>.

These are handled in Drupal\Core\Routing\NullGenerator::getRoute(), but not documented there.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#72 2719611-71.patch2.91 KBroshni27
#70 2719611-70.patch2.99 KBrohan-sinha
#69 2719611-69.patch2.9 KBrohan-sinha
#67 2719611-67.patch2.78 KB_pratik_
#66 2719611-66.patch2.75 KBrohan-sinha
#64 interdiff_60-64.txt2.29 KBranjit1032002
#64 2719611-64.patch2.75 KBranjit1032002
#61 2719611-patch-61.png200.99 KBnikhil_110
#60 interdiff_52_60.txt2.27 KBrishabh vishwakarma
#60 2719611-60.patch2.85 KBrishabh vishwakarma
#59 interdiff_52_59.txt2.27 KBrishabh vishwakarma
#59 2719611-59.patch3.25 KBrishabh vishwakarma
#52 2719611-52.drupal.document-special-route-names.patch2.5 KBjoachim
#51 2719611-nr-bot.txt2.45 KBneeds-review-queue-bot
#50 2719611-50.drupal.document-special-route-names.patch2.52 KBjoachim
#49 2719611-nr-bot.txt2.23 KBneeds-review-queue-bot
#42 After-Patch 2.png58.01 KBmitthukumawat
#42 After-patch 1.png129.26 KBmitthukumawat
#40 2719611-40.patch2.51 KBranjith_kumar_k_u
#30 document_special_route-2719611-30.patch2.63 KBPavan B S
#27 document_special_route-2719611-24.patch921 bytesPavan B S
#22 document_special_route-2719611-22.patch915 bytesdhruveshdtripathi
#17 drupal-documentation-special-route-names-2719611-17.patch781 bytesgaurav.kapoor
#15 drupal-documentation-special-route-names-2719611-14.patch732 bytesgaurav.kapoor
#14 adding_documentation-2719611-2.patch821 bytesgaurav.kapoor
#4 adding_documentation-2719611-4.patch808 bytesashishdalvi
#2 adding_documentation-2719611-2.patch821 bytesPradnya Pingat
#2 adding_documentation-2719611-2.patch821 bytesPradnya Pingat

Issue fork drupal-2719611

Command icon 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:

Comments

joachim created an issue. See original summary.

Pradnya Pingat’s picture

Assigned: Unassigned » Pradnya Pingat
Status: Active » Needs review
StatusFileSize
new821 bytes
new821 bytes

Added documentation for three special routing names.

surbz’s picture

Status: Needs review » Needs work
  1. +++ b/core/lib/Drupal/Core/Routing/NullGenerator.php
    @@ -29,6 +29,14 @@ public function __construct(RequestStack $request_stack) {
    +   * - <none>: The special path that make links relative to the current URL.
    

    "Special path" makes no sense, it should be only "Path"

  2. +++ b/core/lib/Drupal/Core/Routing/NullGenerator.php
    @@ -29,6 +29,14 @@ public function __construct(RequestStack $request_stack) {
    +   * ¶
    

    Remove white space.

ashishdalvi’s picture

Status: Needs work » Needs review
StatusFileSize
new808 bytes

Fixed coding standards issues and suggestions.

ashishdalvi’s picture

Assigned: Pradnya Pingat » Unassigned
dawehner’s picture

Mh, the null generator doesn't really seem to be the best place to document it, don't you think so? This class is for example not used on runtime. Maybe the drupal specific url generator: \Drupal\Core\Routing\UrlGeneratorInterface is a better place.

jhodgdon’s picture

Status: Needs review » Needs work

Yes to #6. Also:

+++ b/core/lib/Drupal/Core/Routing/NullGenerator.php
@@ -29,6 +29,14 @@ public function __construct(RequestStack $request_stack) {
+   *
+   * Available names:
+   * - <front>: The special path that links to the default front page.
+   * - <current>: The special path that links to the current page.
+   * - <none>: Path that make links relative to the current URL.
+   *
+   * @param string $name
+   *   String of routing paths.

This whole documentation area doesn't make sense to me ...

What does "available" names mean?

Also shouldn't it be part of the $name parameter docs?

Also the grammar needs attention.

joachim’s picture

Yup, something like:

@param string $name
  String of routing paths. The following special values may be used:
  - '<front>': The site's front page.
[...etc]

Though I can't figure out the difference between current and none.

vinay15’s picture

Assigned: Unassigned » vinay15
vinay15’s picture

<current> would be to get current page url.
<none> is a menu link with a path to nowhere. See this https://www.drupal.org/node/143322 page which has two issues for Drupal 8:

1. Allow menu items without path
2. Add to allow for non-link links

First one is marked duplicate of Second and Second is fixed, so should we use <nolink> here?

Correct me if I am totally in the wrong direction.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

shashikant_chauhan’s picture

gaurav.kapoor’s picture

Status: Needs work » Needs review
StatusFileSize
new821 bytes

This one should do.

gaurav.kapoor’s picture

StatusFileSize
new732 bytes

Sorry , ignore that one.

joachim’s picture

Status: Needs review » Needs work

The list itself looks good!

+++ b/core/lib/Drupal/Core/Routing/NullGenerator.php
@@ -29,6 +29,14 @@ public function __construct(RequestStack $request_stack) {
+   * - <front>: The site's front page.
+   * - <current>: The current page.
+   * - <none>: The path that make links relative to the current URL.

But this should say what this list means, as without it it's rather confusing.

Something like:

'This defines the following special routes:'

gaurav.kapoor’s picture

Status: Needs work » Needs review
StatusFileSize
new781 bytes
mahesh.gupta’s picture

Assigned: vinay15 » mahesh.gupta

I am working on it

rahul.shinde’s picture

Assigned: mahesh.gupta » Unassigned

I have added review comments for the patch posted on #2719611: Document special route names.

  1. +++ b/core/lib/Drupal/Core/Routing/NullGenerator.php
    @@ -29,6 +29,15 @@ public function __construct(RequestStack $request_stack) {
        * generate(), generateFromRoute(), and getPathFromRoute() all call this
    

    Please update doc comment with capital letter, like 'Functions generate(), generateFromRoute(), and getPathFromRoute() all call this protected method.'

  2. +++ b/core/lib/Drupal/Core/Routing/NullGenerator.php
    @@ -29,6 +29,15 @@ public function __construct(RequestStack $request_stack) {
    +   *   String of routing paths.
    

    Please replace this with 'The special string that generates a routing path.' If you think replacement makes more sense.

  3. +++ b/core/lib/Drupal/Core/Routing/NullGenerator.php
    @@ -29,6 +29,15 @@ public function __construct(RequestStack $request_stack) {
    +   *
    

    Remove this line, as the following line also continuity of the description of $name parameter.

  4. +++ b/core/lib/Drupal/Core/Routing/NullGenerator.php
    @@ -29,6 +29,15 @@ public function __construct(RequestStack $request_stack) {
    +   * This defines the following special routes:
    

    Indentation, (Parameter comment indentation must be 3 spaces)

  5. +++ b/core/lib/Drupal/Core/Routing/NullGenerator.php
    @@ -29,6 +29,15 @@ public function __construct(RequestStack $request_stack) {
    +   * This defines the following special routes:
    +   * - <front>: The site's front page.
    +   * - <current>: The current page.
    +   * - <none>: The path that make links relative to the current URL.
    

    Indentation, (Parameter comment indentation must be 3 spaces)

  6. +++ b/core/lib/Drupal/Core/Routing/NullGenerator.php
    @@ -29,6 +29,15 @@ public function __construct(RequestStack $request_stack) {
    +   *
    

    Remove this additional blank line.

rahul.shinde’s picture

Status: Needs review » Needs work
dhruveshdtripathi’s picture

Assigned: Unassigned » dhruveshdtripathi
dhruveshdtripathi’s picture

Assigned: dhruveshdtripathi » Unassigned
Status: Needs work » Needs review
StatusFileSize
new915 bytes

Made changes suggested in comment #19

dawehner’s picture

I think one thing we should do is to focus our documentation on the bits which are actually used most of the time in the production level environment:

\Drupal\Core\Routing\UrlGeneratorInterface::generateFromRoute and \Drupal\Core\Url. Both \Drupal\Core\Url::fromRoute and \Drupal\Core\Routing\UrlGeneratorInterface::generateFromRoute don't document these special routes. I personally believe putting this information there would be way better.

joachim’s picture

My feeling is that documentation should be close to the code that it's documenting, so that if the special routes ever change, or are added to or removed, we notice the documentation change that would also be required.

But we could put a @see in both \Drupal\Core\Url::fromRoute and \Drupal\Core\Routing\UrlGeneratorInterface::generateFromRoute that points here.

dawehner’s picture

I think one thing we should do is to focus our documentation on the bits which are actually used most of the time in the production level environment:

\Drupal\Core\Routing\UrlGeneratorInterface::generateFromRoute and \Drupal\Core\Url. Both \Drupal\Core\Url::fromRoute and \Drupal\Core\Routing\UrlGeneratorInterface::generateFromRoute don't document these special routes. I personally believe putting this information there would be way better.

Pavan B S’s picture

Assigned: Unassigned » Pavan B S
Status: Needs review » Needs work
+++ b/core/lib/Drupal/Core/Routing/NullGenerator.php
@@ -27,8 +27,15 @@ public function __construct(RequestStack $request_stack) {
+   * Functions generate(), generateFromRoute(), and getPathFromRoute() all call this

Line exceeding 80 characters

Pavan B S’s picture

Status: Needs work » Needs review
StatusFileSize
new921 bytes

Modified one line which contain more than 80 characters. Applying the patch.

Pavan B S’s picture

Assigned: Pavan B S » Unassigned
dawehner’s picture

Status: Needs review » Needs work

Neither of the latest comment got addressed in your latest patch. Please reach out if you need help.

Pavan B S’s picture

Status: Needs work » Needs review
StatusFileSize
new2.63 KB

Made changes as per the suggestion in comment #25 , Please Review the patch and correct me if i am wrong.

joachim’s picture

Thanks for updating the patch, but the problem is that that now repeats the documentation, which makes it harder to maintain.

@dawehner please could you respond to my point and suggestion in #24?

dawehner’s picture

My feeling is that documentation should be close to the code that it's documenting, so that if the special routes ever change, or are added to or removed, we notice the documentation change that would also be required.

But we could put a @see in both \Drupal\Core\Url::fromRoute and \Drupal\Core\Routing\UrlGeneratorInterface::generateFromRoute that points here.

That's a tricky question ... for me having duplicate documentation is better than having people troubling with finding it in the first place.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

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

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

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.

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.

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

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

ranjith_kumar_k_u’s picture

StatusFileSize
new2.51 KB

Re-rolled for 9.2

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

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

mitthukumawat’s picture

StatusFileSize
new129.26 KB
new58.01 KB

Patch #40 applied successfully. Adding screenshots of diff for reference. RTBC +1

quietone’s picture

@mitthukumawat, thanks for the interest. Reviewing a patch will help an issue move forward. The contributor guide contains move information about contributing.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

vikashsoni’s picture

Applied patch #40 in drupal-9.3.x-dev applied successfully
After patch getting expected result mention in tickets
Thanks for the patch

hmendes’s picture

The patch looks good for me to change to RTBC, but I'm just worried about #31 and #32, should we keep the duplicated documentation?

As the $options param from the Url construct function:

   * @param array $options
   *   See \Drupal\Core\Url::fromUri() for details.
   *

Shouldn't we do the same thing for the route_name?
Something like

   * @param string $route_name
   *   @see \Drupal\Core\Routing\NullGenerator.php::getRoute for details.
   *

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new2.23 KB

The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

joachim’s picture

Status: Needs work » Needs review
StatusFileSize
new2.52 KB

Rerolled.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new2.45 KB

The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

joachim’s picture

Status: Needs work » Needs review
StatusFileSize
new2.5 KB
ranjit1032002’s picture

Status: Needs review » Reviewed & tested by the community

I had Reviewed the patch and it's working as expected mentioned in comment #52

rohan-sinha’s picture

great work joachim, patch is all working fine and thanks ranjit for reviewing, reviewing a patch will help an issue move forward. The contributor guide contains move information about contributing.

jungle’s picture

Status: Reviewed & tested by the community » Needs review
<?php

namespace Drupal\Core;

/**
 * This class holds a <span> generated from the <nolink> route.
 */
class GeneratedNoLink extends GeneratedLink {

  /**
   * {@inheritdoc}
   */
  const TAG = 'span';

}

<nolink> is a special route too, which is not documented by the patch here, is it irrelevant here?

jungle’s picture

Title: document special route names » Document special route names
Category: Bug report » Task
Priority: Normal » Minor

Not a bug, could be a Minor

jungle’s picture

Issue summary: View changes

Apply the issue summary(IS) template only. If #55 is a thing, then needs updating IS.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative

@jungle that is a valid route that can be added to the link so think it should be included as well.

rishabh vishwakarma’s picture

Status: Needs work » Needs review
StatusFileSize
new3.25 KB
new2.27 KB

Addressed #58 and added to the patch

rishabh vishwakarma’s picture

StatusFileSize
new2.85 KB
new2.27 KB

Fixed CCF from #59

nikhil_110’s picture

StatusFileSize
new200.99 KB

Patch #60 is applied successfully and screenshot is also attached.

aziza_a’s picture

Status: Needs review » Reviewed & tested by the community

Checked the patch given in #60 works properly

longwave’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/lib/Drupal/Core/Routing/NullGenerator.php
    @@ -28,6 +28,14 @@ public function __construct(RequestStack $request_stack) {
    +   *   - <nolink>: Used to enter a link, but only the text of the link to be shown, without actually creating a link.
    

    This needs wrapping at 80 characters.

  2. +++ b/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php
    @@ -15,7 +15,13 @@ interface UrlGeneratorInterface extends SymfonyUrlGeneratorInterface {
    +   *   @see \Drupal\Core\Routing\NullGenerator.php::getRoute
    

    This @see is not valid; it can't be part of @param and the .php extension shouldn't be added to the class name. Not even sure we need an @see here?

ranjit1032002’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new2.75 KB
new2.29 KB

Attaching patch and interdiff for the issue mentioned in comment #63

smustgrave’s picture

Status: Needs review » Needs work

Build failure in #64

rohan-sinha’s picture

StatusFileSize
new2.75 KB

removing errors from patch #64

_pratik_’s picture

Status: Needs work » Needs review
StatusFileSize
new2.78 KB

Please try this patch for 10.1.x

smustgrave’s picture

Status: Needs review » Needs work
+   *   - <nolink>: Used to enter a link,
+   *   but only the text of the link to be shown,
+   *   without actually creating a link.

that visually just doesn't read right.

rohan-sinha’s picture

StatusFileSize
new2.9 KB

Modified the patch as requested.

rohan-sinha’s picture

StatusFileSize
new2.99 KB

Adding again with modification of #69.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

roshni27’s picture

Status: Needs work » Needs review
StatusFileSize
new2.91 KB

same patch for 11.x.

Status: Needs review » Needs work

The last submitted patch, 72: 2719611-71.patch, failed testing. View results

roshni27’s picture

Status: Needs work » Needs review

Patch #70 has successfully passed the test in version 11.x, hence it should be moved to the "needs review"

joachim’s picture

Status: Needs review » Reviewed & tested by the community
needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work

The Needs Review Queue Bot tested this issue.

While you are making the above changes, we recommend that you convert this patch to a merge request. Merge requests are preferred over patches. Be sure to hide the old patch files as well. (Converting an issue to a merge request without other contributions to the issue will not receive credit.)

shweta__sharma made their first commit to this issue’s fork.

shweta__sharma’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

So #72 was not needed as #70 still applies cleanly to 11.x, same for the MR Ticket could of been put back into RTBC

longwave’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/lib/Drupal/Core/Routing/NullGenerator.php
@@ -28,6 +28,16 @@ public function __construct(RequestStack $request_stack) {
+   *   - <nolink>: Used to create text that appears as a link,
+   *   but does not lead to an actual URL, only the text
+   *   of the link is displayed without an actual link.

The second/third lines of the bullet point need to be indented another two characters. Also this can be wrapped more closely to 80 characters.

Same for the other instances of this.

Akhil Babu made their first commit to this issue’s fork.

akhil babu’s picture

Status: Needs work » Needs review

Updated as per #81

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

#81 indentation has been addressed.

longwave’s picture

Status: Reviewed & tested by the community » Needs work

Still not sure this is quite right, added some more suggestions.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.