Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
<code>
- global $language_interface;
+ $language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
This seems unnecessarily verbose. For lock/queue etc. moving to the container we've left in global procedural wrappers which just call drupal_container() so there's a convenient way to access it. What about something like that for language? Or is there a way to make the drupal_container() call itself a bit prettier?
If everything is injected we don't have this problem, but I don't see that completely going away during this release cycle so it'd be good to have even an interim solution.
Comment | File | Size | Author |
---|---|---|---|
#14 | 1630050.patch | 57.83 KB | RobLoach |
#10 | 1630050-replace_language_drupal_language-10.patch | 57.22 KB | Cameron Tod |
#7 | 1630050-replace_language_drupal_language-7.patch | 57.14 KB | Cameron Tod |
#5 | 1630050-replace_language_drupal_language.patch | 57.13 KB | Cameron Tod |
Comments
Comment #1
RobLoachWe were playing with the idea of a
drupal($service)
function that would retrieve the desired service.But, in the end, a wrapper function is just a wrapper function. It doesn't actually help you architecturally. For that reason, we've been focusing on getting the objects in there first, and worrying about minuet micro-syntax-optimizations like that later. We don't want to be STUPID ;-) .
Regarding the language system, the end goal is to move drupal_language_initialize() to a LanguageSystem class, and a "language" service. This means that there would not be a language bootstrap as the entire language system would be lazy-loaded the first time you try to use it. I believe that's at #1550866: Remove obsolete drupal_language_initialize().
Comment #2
catchdrupal($service) could be fun. Yeah there's no architectural benefit here, but it's also no fun walking around a building site to get into a nicely architected building either ;)
Comment #3
alexweber CreditAttribution: alexweber commentedCan we close this in light of #2001206: Replace drupal_container() with Drupal::service()?
Comment #4
BerdirWow, that's an old issue ;)
This changed a lot already, we have the language() function now, which we should move to the Drupal class as it's a "service-exposing" function.
Comment #5
Cameron Tod CreditAttribution: Cameron Tod commentedGetting weird test errors here that are a bit beyond me. Let's see how this goes with the testbot while I continue to hack away.
Comment #7
Cameron Tod CreditAttribution: Cameron Tod commentedWoops, missing a namespacing.
Comment #9
BerdirYou need to use \Drupal in classes.
Comment #10
Cameron Tod CreditAttribution: Cameron Tod commentedThanks ack - hopefully I got them all.
Comment #12
Cameron Tod CreditAttribution: Cameron Tod commented#10: 1630050-replace_language_drupal_language-10.patch queued for re-testing.
Comment #14
RobLoachWe might be able to move the service registration into the CoreBundle. There might be instances where we can't do this though. Let's see what the test bot says.
Comment #16
Cameron Tod CreditAttribution: Cameron Tod commented#14: 1630050.patch queued for re-testing.
Comment #18
Cameron Tod CreditAttribution: Cameron Tod commented#10: 1630050-replace_language_drupal_language-10.patch queued for re-testing.
Comment #19
Berdir#14: 1630050.patch queued for re-testing.
Comment #20.0
(not verified) CreditAttribution: commentedUpdating summary.
Comment #21
Berdirlanguage() is gone, closing.