Follow-up from #1599108: Allow modules to register services and subscriber services (events). The new language_manager() function doesn't return a manager, it returns a language. Therefore, rename it to language(). This is consistent with our pattern for cache() and similar functions.

This also cleans up a few things in the language() function body.

Files: 
CommentFileSizeAuthor
drupal-language_manager_cleanup.patch50.36 KBeffulgentsia
PASSED: [[SimpleTest]]: [MySQL] 39,881 pass(es).
[ View ]

Comments

Status:Needs review» Reviewed & tested by the community
Issue tags:+API clean-up, +Dependency Injection (DI), +kernel-followup

Thanks!

+++ b/core/includes/bootstrap.inc
@@ -2619,56 +2620,61 @@ function drupal_language_initialize() {
+  // We don't use drupal_static() here because resetting is not a simple case of
+  // drupal_static_reset().
+  static $languages = array();

I still have no idea how and where this static is reset for test runs... unless I'm mistaken, the languages are massively leaking into tests right now.

+++ b/core/includes/bootstrap.inc
@@ -2619,56 +2620,61 @@ function drupal_language_initialize() {
+  // When the language_manager service exists (is both defined and the 'request'
+  // scope is active in the container), use it to get the language. Otherwise
+  // return the default language.
+  try {
+    $language_manager = drupal_container()->get('language_manager', Container::NULL_ON_INVALID_REFERENCE);
   }

I also do not understand why we don't simply have a NonRequestContainer or HeadlessContainer, instead of those hard-coded lines in drupal_container(), and instead of this procedural language() helper.

But anyway, this patch is a good clean-up on its own, which simplifies and clarifies that current workaround.

Status:Reviewed & tested by the community» Fixed

Committed to 8.x. Thanks.

Title:Rename language_manager() to language() and related cleanupChange notification for: Rename language_manager() to language() and related cleanup
Priority:Normal» Critical
Status:Fixed» Active

Okay, then THIS can be the issue to fix the language docs on http://drupal.org/node/1539454

Title:Change notification for: Rename language_manager() to language() and related cleanupRename language_manager() to language() and related cleanup
Priority:Critical» Normal
Status:Active» Fixed

I updated this myself.
This would have been enough for us to know how to update Views, which should be enough.

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