Drupal 8 Depreciated Code

Vipin Mittal
Feb 3, 2021

Drupal 8: public static function Drupal::url (https://api.drupal.org/api/drupal/core%21lib%21Drupal.php/function/Drupal%3A%3Aurl/8.9.x)
Drupal9: class Url (https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Url.php/class/Url/9.2.x)
Example: \Drupal::url($route_name, $route_parameters = [], $options = []); with Url::fromRoute($route_name, $route_parameters = [], $options = []);

Drupal 8: drupal_set_message()
Drupal9: \Drupal::messenger()->addMessage();
Example: drupal_set_message($message) with \Drupal::messenger()->addMessage($message);

Drupal 8: drupal_render()
Drupal9: \Drupal::service(‘renderer’)->render();
Example: drupal_render($render)with \Drupal::service(‘renderer’)->render($render);

Drupal 8: public static function Drupal::l (https://api.drupal.org/api/drupal/core!lib!Drupal.php/function/Drupal%3A%3Al/8.9.x)
Drupal9: public static function Link::fromTextAndUrl (https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Link.php/function/Link%3A%3AfromTextAndUrl/9.2.x)
Example: \Drupal::l($text, $url); with Link::fromTextAndUrl($text, $url);

--

--

Vipin Mittal

He is Passionate coder and Drupal enthusiast with 15 years core Drupal experience. He is Acquia Drupal certified and involved in different upgrades/migrations.