Problem/Motivation

As of https://docs.google.com/document/d/1BxgNvyIRcxYGzzA1DLkZ6A4-c8gGFixypNvP... we want to make clear which bits of the URL generation
machinery should be used

\Drupal::l() is one of them

Proposed resolution

* mark \Drupal::l() as deprecated, see #2605546: Mark \Drupal::url() as deprecated for a related example
* Point to \Drupal\Core\Link instead

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner created an issue. See original summary.

dawehner’s picture

Component: base system » documentation
sdstyles’s picture

Status: Active » Needs review
FileSize
551 bytes
Himanshu5050’s picture

joshi.rohit100’s picture

@Himanshu5050 - Please try to upload the interdiff as well as I couldn't tell the difference between #3 and #4

nicrodgers’s picture

Status: Needs review » Reviewed & tested by the community

The patch in #3 looks good to me. The patch in #4 has less information (does not say when it will be removed). So #3 RTBC

nicrodgers’s picture

Status: Reviewed & tested by the community » Needs work

Actually...feedback on #3

+++ b/core/lib/Drupal.php
@@ -550,6 +550,9 @@ public static function linkGenerator() {
+   *   Use \Drupal\Core\Link instead.

Would be helpful (and consistent with the other example) to provide more information, such as:

Instead create a \Drupal\Core\Url object directly, for example using Url::fromRoute().

rakesh.gectcr’s picture

Assigned: Unassigned » rakesh.gectcr
rakesh.gectcr’s picture

Status: Needs work » Needs review
FileSize
626 bytes

@nicrodgers,

I have updated your comments #6 and #7.

rakesh.gectcr’s picture

I have modified the example of usage;

@@ -550,6 +550,13 @@ public static function linkGenerator() {
    *
    * @see \Drupal\Core\Utility\LinkGeneratorInterface::generate()
    * @see \Drupal\Core\Url
+   *
+   * @deprecated in Drupal 8.0.0 will be removed before Drupal 9.0.0.
+   *   Use \Drupal\Core\Url instead.
+   *   Example:
+   *   @code
+   *     \Drupal\Core\Url::fromRoute()
+   *   @endcode
jhodgdon’s picture

Component: documentation » base system

Deciding that something is deprecated is not a Documentation issue.

dawehner’s picture

@jhodgdon
Well this was already totally decided, so you think the deprecation step is its own thing and should be still discussed?

dawehner’s picture

  1. +++ b/core/lib/Drupal.php
    @@ -550,6 +550,13 @@ public static function linkGenerator() {
    +   *   Use \Drupal\Core\Url instead.
    

    You should use the Link object instead ...

  2. +++ b/core/lib/Drupal.php
    @@ -550,6 +550,13 @@ public static function linkGenerator() {
    +   *     \Drupal\Core\Url::fromRoute()
    

    Let's use $link = Link::fromTextAndUrl($text, $url); as example

dawehner’s picture

Status: Needs review » Needs work
rakesh.gectcr’s picture

@dawehner

I updated the patch according to above comments.

+   *
+   * @deprecated in Drupal 8.0.0 will be removed before Drupal 9.0.0.
+   *   Use \Drupal\Core\Link instead.
+   *   Example:
+   *   @code
+   *     $link = Link::fromTextAndUrl($text, $url);
+   *   @endcode
    */
rakesh.gectcr’s picture

Status: Needs work » Needs review
dawehner’s picture

Issue tags: +rc eligible

Thank you

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

.

  • xjm committed 619a1c9 on 8.1.x
    Issue #2606376 by rakesh.gectcr, Himanshu5050, sdstyles, dawehner,...

  • xjm committed 53a404c on
    Issue #2606376 by rakesh.gectcr, Himanshu5050, sdstyles, dawehner,...
xjm’s picture

Component: base system » routing system
Status: Reviewed & tested by the community » Fixed

I think it does make sense to file the deprecations against their respective component.

Committed and pushed to 8.1.x and 8.0.x (with the addition of the missing word "and" fixed on commit). Thanks all for working on this!

Status: Fixed » Closed (fixed)

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