Add core_version_requirement: ^8 || ^9 to languageicons.info.yml to designate that the theme is compatible with Drupal 9.
See https://www.drupal.org/node/3070687.

drupal-check & rector reports below :-

vendor/bin/rector process web/modules/contrib/languageicons --dry-run
Rector 0.8.x-dev@8896f0a
Config file: rector.yml

 9/9 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

2 files with changes
====================

1) web/modules/contrib/languageicons/languageicons.module

    ---------- begin diff ----------
--- Original
+++ New
@@ -1,4 +1,6 @@
 <?php
+use Drupal\Core\Url;
+use Drupal\Component\Utility\Html;
 /**
  * @file
  * Icons for language links.
@@ -38,7 +40,7 @@
       $output .= '<p>' . t('For more information, please see <a href="@handbook">the online handbook section</a>.', array('@handbook' => 'http://drupal.org/node/133977')) . '</p>';
       return $output;
     case 'admin/config/regional/language/icons':
-      $output = '<p>' . t('To enable multilingual support for specific content types go to <a href="@configure_content_types">configure content types</a>.', array('@configure_content_types' => \Drupal\Core\Url::fromRoute('entity.node_type.collection'))) . '</p>';
+      $output = '<p>' . t('To enable multilingual support for specific content types go to <a href="@configure_content_types">configure content types</a>.', array('@configure_content_types' => Url::fromRoute('entity.node_type.collection'))) . '</p>';
       return $output;
   }
 }
@@ -104,7 +106,7 @@
   if ($path = \Drupal::config('languageicons.settings')->get('path')) {
     $variables['icon'] = [
       '#theme' => 'image',
-      '#uri' => str_replace('*', $language->getId(), \Drupal\Component\Utility\Html::escape($path)),
+      '#uri' => str_replace('*', $language->getId(), Html::escape($path)),
       '#alt' => $title,
       '#title' => $title,
       '#width' => $width,
    ----------- end diff -----------

2) web/modules/contrib/languageicons/src/Form/LanguageiconsAdminSettings.php

    ---------- begin diff ----------
--- Original
+++ New
@@ -40,7 +40,7 @@
     return ['languageicons.settings'];
   }

-  public function buildForm(array $form, \Drupal\Core\Form\FormStateInterface $form_state) {
+  public function buildForm(array $form, FormStateInterface $form_state) {
     $form['show'] = [
       '#type' => 'fieldset',
       '#title' => t('Add language icons'),
    ----------- end diff -----------


 [OK] Rector is done! 2 files would have changed (dry-run).



vendor/bin/drupal-check -ad web/modules/contrib/languageicons
 3/3 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%



 [OK] No errors

CommentFileSizeAuthor
#2 3131753-2.patch2.47 KBrahulrasgon

Comments

rahulrasgon created an issue. See original summary.

rahulrasgon’s picture

StatusFileSize
new2.47 KB

Added a patch. Kindly review.

rahulrasgon’s picture

Assigned: rahulrasgon » Unassigned
Status: Needs work » Needs review
hardik_patel_12’s picture

Status: Needs review » Reviewed & tested by the community

patch #2 applies cleanly and installed this on Drupal 9 instance.

Ran drupal-check and found no issues:

 drupal-check -ad modules/contrib/languageicons                        
PHPStan crashed in the previous run probably because of excessive memory consumption.
It consumed around 42 MB of memory.


To avoid this issue, allow to use more memory with the --memory-limit option.
 3/3 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

                                                                                                                        
 [OK] No errors
kristen pol’s picture

Issue tags: -Drupal 9 readiness
heddn’s picture

+1 on RTBC. And after landing this, can we get a new tagged beta release?

+++ b/languageicons.module
@@ -1,4 +1,6 @@
+use Drupal\Core\Url;
+use Drupal\Component\Utility\Html;

@@ -38,7 +40,7 @@ function languageicons_help($path, $arg) {
+      $output = '<p>' . t('To enable multilingual support for specific content types go to <a href="@configure_content_types">configure content types</a>.', array('@configure_content_types' => Url::fromRoute('entity.node_type.collection'))) . '</p>';

@@ -104,7 +106,7 @@ function template_preprocess_languageicons_link_content(&$variables) {
+      '#uri' => str_replace('*', $language->getId(), Html::escape($path)),

+++ b/src/Form/LanguageiconsAdminSettings.php
@@ -40,7 +40,7 @@ class LanguageiconsAdminSettings extends ConfigFormBase {
+  public function buildForm(array $form, FormStateInterface $form_state) {

These changes aren't strictly needed for D9 compatibility. They could be done as clean-up, but the key thing is the core version requirement change.

pfrenssen’s picture

pfrenssen’s picture

Title: [META] Make Language Icons compatible with Drupal 9.x » Make Language Icons compatible with Drupal 9.x
Status: Reviewed & tested by the community » Fixed

Thanks!

  • pfrenssen committed 03519f2 on 8.x-1.x authored by rahulrasgon
    Issue #3131753 by rahulrasgon, Hardik_Patel_12, Kristen Pol, heddn: Make...

Status: Fixed » Closed (fixed)

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