The language_list function don't exist anymore on Drupal 8.
Please use \Drupal::languageManager()->getLanguages();

Thank you.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mgoncalves created an issue. See original summary.

mgoncalves’s picture

Assigned: mgoncalves » Unassigned
Status: Active » Needs review
FileSize
598 bytes
hgunicamp’s picture

Status: Needs review » Reviewed & tested by the community

After applying the 'taxonomy_manager-change_laguage_list_function-2876116-8x.patch' patch and using the command

find . -type f \( -name '*.inc' -or -name '*.php' \) -exec grep --color=auto -e '\blanguage_list' {} \+

I did not find more 'language_list' occurrences.

So the patch worked for me.

JacobSanford’s picture

Title: Change language_list() to getLanguages(). » Change language_list() and locale_language_list() to getLanguages().
Status: Reviewed & tested by the community » Needs work

Thanks for the contributions, but I don't quite think we're there yet. This is a bit of a can of worms.

getLanguages() returns an array of Language Objects whereas language_list() returned an array of associative arrays keyed by strings like 'language' and 'name'.

As a result, accesses to the object and its properties within the loop are not done correctly:

    foreach ($languages as $language) {
      $translation = isset($term->translations->data[$language->language]) ? $term->translations->data[$language->language] : FALSE;

      // Determine the access for each translation.
      if ($translation) {
        $access = entity_translation_access('taxonomy_term', $translation);
      }
      else {
        $access = (user_access('translate any entity') || user_access('translate taxonomy_term entities'));
      }
      if (entity_translation_workflow_enabled() && $source_language == $language->language) {
        $access = user_access('edit original values');
      }
      <...>

Correcting this involves moving to LanguageInterface::getName and LanguageInterface::getName where appropriate (if the use of objects isn't desired). In particular, the use of $language->language, which AFAICT will not work at all.

In accordance with #1387608: Unify language_list() and locale_language_list(), we should also try to target use of locale_language_list() in the module within this issue.

I see several uses:

./taxonomy_manager.admin.inc:        '#options' => array('' => t('All'), 'no language' => t('no language')) + locale_language_list('name'),
./taxonomy_manager.admin.inc:        '#options' => array('' => t('All'), 'no language' => t('no language')) + locale_language_list('name'),
./taxonomy_manager.admin.inc:          '#options' => locale_language_list('name'),
./taxonomy_manager.admin.inc:  $languages = locale_language_list('name');

Do note that as with above, a direct substitution with getLanguages() will not work. locale_language_list() returned an array of language names keyed by code.

Shashwat Purav’s picture

Issue tags: +DrupalMumbaiCodeSprint

Assigning this issue for Drupal Mumbai Code Sprint Dec 2017.

sonvir249’s picture

Assigned: Unassigned » sonvir249
sonvir249’s picture

Status: Needs work » Needs review
FileSize
6.01 KB

Hi @JacobSanford,
Patch added as suggested.

Thank You!

navneet0693’s picture

Status: Needs review » Needs work
+++ b/taxonomy_manager.admin.inc
@@ -1141,8 +1141,10 @@ function taxonomy_manager_term_data_form_entity_translation(&$form, $term) {
+    debug($term, '$term');

debug ?

sonvir249’s picture

Status: Needs work » Needs review
FileSize
5.98 KB

Hi @navneet0693,
debug function removed.

Thanks!

JacobSanford’s picture

Status: Needs review » Closed (outdated)

Hi Everyone,

Thanks for your help here. I appreciate the contributions.

It appears that this issue has been dated-out by the deletion of the .admin.inc file

#2849948: Missing Include

Closing.