At the moment we have very few usages of Drupal::service('language_manager') throughout core, but as soon as #1862202: Objectify the language system lands this number will explode, AAMOF all occurrences of language_list() will be deprectaed in favor of direct calls to the language manager.

This seems a good time to add the helper Drupal::languageManager() method.

#1 language-service_wrapper-2020249-1.patch1.54 KBplach
PASSED: [[SimpleTest]]: [MySQL] 57,650 pass(es). View
Members fund testing for the Drupal project. Drupal Association Learn more


plach’s picture

Status: Active » Needs review
Issue tags: +Quick fix
1.54 KB
PASSED: [[SimpleTest]]: [MySQL] 57,650 pass(es). View

And here it is.

ParisLiakos’s picture

Status: Needs review » Reviewed & tested by the community

makes sense

Berdir’s picture

Agreed. And this is fine to get in.

That said, Drupal::languageManager()->getLanguage(Language::TYPE_INTERFACE) is still quite ugly, among other things because you need a use for Language and we went to great length to avoid that you have to use Drupal in procedural code. Of which we have less and less but still a fair bit and contrib will have a lot.

So, given that we have constants for those anyway, what about introducing helper methods (in a follow-up issue, of course) for those hardcoded types: Drupal::languageManager()->getInterfaceLanguage()?

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 6012988 and pushed to 8.x. Thanks!

Berdir’s picture

Gábor Hojtsy’s picture

Issue tags: -sprint

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

Anonymous’s picture

Issue summary: View changes

Updated issue summary.