Problem/Motivation

Drupal\Core\Utility is filled with classes that have all static methods, most of which have no external dependencies.

LinkGenerator is a service.

We've made a distinction between Services and Utility classes, we should keep that.

This also applies to #2346361: Add a UnroutedUrlAssembler and put it into the container

Proposed resolution

Move LinkGenerator to a new namespace: Drupal\Core\Render\LinkGenerator

Remaining tasks

 

Contributor tasks needed
Task Novice task? Contributor instructions Complete?
Create a patch Instructions

User interface changes

API changes

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Task because it functions normally without the change (not a bug)
Issue priority Minor because nothing is currently broken.
Unfrozen changes It's frozen because it changes namespaces
Prioritized changes Possibly a prioritized DX improvement.
Disruption Disruptive for current patches in core which touch LinkGenerator. Other code will be using the service, which will be somewhat more namespace-agnostic. Patches which use the service will need to double-check their @var documentation.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

I don't think this is novice as we originally had big issues finding a better namespace.

tim.plunkett’s picture

Right, deciding the namespace isn't novice, but performing the move will be.

Palashvijay4O’s picture

Assigned: Unassigned » Palashvijay4O
Status: Active » Needs review
FileSize
18.61 KB

Submitting a patch .

tim.plunkett’s picture

@Palashvijay4 I think this was the wrong patch?

jibran’s picture

Status: Needs review » Needs work

NW for #4

Palashvijay4O’s picture

Sir @tim.plunkett why the patch is not correct ?

tim.plunkett’s picture

All the patch does is remove the LinkGeneratorTest, and change unrelated CSS.

It does not touch LinkGenerator at all.

alimac’s picture

Issue summary: View changes
rpayanm’s picture

any progress @Palashvijay4O?

dawehner’s picture

Assigned: Palashvijay4O » Unassigned

We should not assign issues anyway these days.

rpayanm’s picture

Then, which is the new namespace for LinkGenerator? I like work on this!

dawehner’s picture

Then, which is the new namespace for LinkGenerator? I like work on this!

Well, that is the point of the issue, find a good one.

Do you have a good suggestion?

mpdonadio’s picture

It generates HTML, so Drupal\Core\Render would potentially be valid, and this is where the render service landed.

It's related to routing, so Drupal\Core\Routing may make sense. Same could be said for Drupal\Core\Path.

It could go in a new namespace in case there are any other link related activities in the future, Drupal\Core\Link

Of those, since the output of this service is HTML, then Drupal\Core\Render is most appropriate.

borisson_’s picture

FileSize
19.04 KB

I agree that Drupal\Core\Render makes the most sense, I've added a patch that implements this change.

tadityar’s picture

Status: Needs work » Needs review

status change so bot will test.

Status: Needs review » Needs work

The last submitted patch, 14: 2346431-14.patch, failed testing.

RavindraSingh’s picture

If Linkgenerator is moving out from unitlity so LinkGenratorInterface and LinkGeneratorTest should moved out

use Drupal\Core\Utility\LinkGeneratorInterface;
use Drupal\Tests\Core\Utility\LinkGeneratorTest;

Should be

use Drupal\Core\render\LinkGeneratorInterface;
use Drupal\Tests\render\Utility\LinkGeneratorTest;

tadityar’s picture

Status: Needs work » Needs review
FileSize
37.73 KB
28.66 KB

Trying. I also moved LinkGeneratorInterface and the test to Render. Please correct me if I'm wrong.

Status: Needs review » Needs work

The last submitted patch, 18: 2346431-17.patch, failed testing.

tadityar’s picture

Status: Needs work » Needs review
FileSize
37.73 KB

Forgot to change the namespace in LinkGeneratorTest.php . Changed now

shivanshuag’s picture

Status: Needs review » Needs work

@tadityar The patch should also remove LinkGenerator.php and LinkGeneratorInterface.php from core/tests/Drupal/Tests/Core/Utility/ and LinkGeneratorTest.php from core/tests/Drupal/Tests/Core/Utility/

tadityar’s picture

Status: Needs work » Needs review
FileSize
61.88 KB

@shivanshu: oops, updated!

tadityar’s picture

FileSize
19.73 KB

I realized that if do the method in patch #22 It'll remove the history of the file. So this time I used git diff -C --staged instead.

tadityar’s picture

FileSize
10.51 KB

Adding interdiff.

dawehner’s picture

Someone should update the issue summary and add a beta evalulation to explain how useful this is, or not.

tadityar’s picture

Priority: Normal » Minor
Issue summary: View changes

Added beta evaluation and priority change. Please correct me if I'm wrong.

tadityar’s picture

Issue summary: View changes
dawehner’s picture

This itself looks fine, thank you!

What is your oppinion here, do you think its worth broken existing people's code due to the renaming of the namespace?

tadityar’s picture

@dawehner I think that it depends on how often this class is used, but since I don't know how often it is I'm not sure.

dawehner’s picture

Well, that classed is used quite often, given that it will be used to create links, actually it is one of the most often used ones.

tadityar’s picture

So, will we move this at all? Maybe it can be closed(won't fix)?

Mile23’s picture

Reroll.

Status: Needs review » Needs work

The last submitted patch, 32: 2346431_32.patch, failed testing.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.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.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should 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.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should 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.

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

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should 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.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should 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.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should 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.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.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.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

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

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should 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.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should 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.

Version: 9.5.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. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.