Unverified Commit ae248f2e authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3047801 by Eduardo Morales, mikelutz, pguillard, nlisgo,...

Issue #3047801 by Eduardo Morales, mikelutz, pguillard, nlisgo, sathish.redcrackle, Berdir: Replace all calls to the deprecated Drupal::l() function in Core
parent 7325b708
Loading
Loading
Loading
Loading
+5 −7
Original line number Diff line number Diff line
@@ -606,17 +606,15 @@ public static function linkGenerator() {
   *   A GeneratedLink object containing a link to the given route and
   *   parameters and bubbleable metadata.
   *
   * @deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use
   * \Drupal\Core\Link::fromTextAndUrl() instead.
   *
   * @see https://www.drupal.org/node/2614344
   * @see \Drupal\Core\Utility\LinkGeneratorInterface::generate()
   * @see \Drupal\Core\Url
   *
   * @deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0.
   *   Use \Drupal\Core\Link instead.
   *   Example:
   *   @code
   *     $link = Link::fromTextAndUrl($text, $url);
   *   @endcode
   */
  public static function l($text, Url $url) {
    @trigger_error('\Drupal::l() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Link::fromTextAndUrl() instead. See https://www.drupal.org/node/2614344', E_USER_DEPRECATED);
    return static::getContainer()->get('link_generator')->generate($text, $url);
  }

+2 −1
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@

use Drupal\Core\Database\Database;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\Core\Utility\UpdateException;

@@ -952,7 +953,7 @@ function hook_requirements($phase) {
  // Test PHP version
  $requirements['php'] = [
    'title' => t('PHP'),
    'value' => ($phase == 'runtime') ? \Drupal::l(phpversion(), new Url('system.php')) : phpversion(),
    'value' => ($phase == 'runtime') ? Link::fromTextAndUrl(phpversion(), Url::fromRoute('system.php'))->toString() : phpversion(),
  ];
  if (version_compare(phpversion(), DRUPAL_MINIMUM_PHP) < 0) {
    $requirements['php']['description'] = t('Your PHP installation is too old. Drupal requires at least PHP %version.', ['%version' => DRUPAL_MINIMUM_PHP]);
+2 −1
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace Drupal\Core\Render\Element;

use Drupal\Core\Link as BaseLink;
use Drupal\Core\Url as BaseUrl;
use Drupal\Component\Utility\NestedArray;

@@ -78,7 +79,7 @@ public static function preRenderCompactLink($element) {
    }

    $options = NestedArray::mergeDeep($element['#url']->getOptions(), $element['#options']);
    $element['#markup'] = \Drupal::l($element['#title'], $element['#url']->setOptions($options));
    $element['#markup'] = BaseLink::fromTextAndUrl($element['#title'], $element['#url']->setOptions($options))->toString();

    return $element;
  }
+2 −1
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@

use Drupal\Component\Utility\Xss;
use Drupal\Core\Render\RenderContext;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
use Drupal\views\Views;
@@ -111,7 +112,7 @@ public function testAggregatorItemView() {
    // Ensure that the rendering of the linked title works as expected.
    foreach ($view->result as $row) {
      $iid = $view->field['iid']->getValue($row);
      $expected_link = \Drupal::l($items[$iid]->getTitle(), Url::fromUri($items[$iid]->getLink(), ['absolute' => TRUE]));
      $expected_link = Link::fromTextAndUrl($items[$iid]->getTitle(), Url::fromUri($items[$iid]->getLink(), ['absolute' => TRUE]))->toString();
      $output = $renderer->executeInRenderContext(new RenderContext(), function () use ($view, $row) {
        return $view->field['title']->advancedRender($row);
      });
+2 −1
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@

use Drupal\Component\Utility\Html;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\language\ConfigurableLanguageInterface;
use Drupal\system\Entity\Menu;
@@ -43,7 +44,7 @@ function block_help($route_name, RouteMatchInterface $route_match) {
    $demo_theme = $route_match->getParameter('theme') ?: \Drupal::config('system.theme')->get('default');
    $themes = \Drupal::service('theme_handler')->listInfo();
    $output = '<p>' . t('Block placement is specific to each theme on your site. Changes will not be saved until you click <em>Save blocks</em> at the bottom of the page.') . '</p>';
    $output .= '<p>' . \Drupal::l(t('Demonstrate block regions (@theme)', ['@theme' => $themes[$demo_theme]->info['name']]), new Url('block.admin_demo', ['theme' => $demo_theme])) . '</p>';
    $output .= '<p>' . Link::fromTextAndUrl(t('Demonstrate block regions (@theme)', ['@theme' => $themes[$demo_theme]->info['name']]), Url::fromRoute('block.admin_demo', ['theme' => $demo_theme]))->toString() . '</p>';
    return $output;
  }
}
Loading