The two functions in core/standard.inc should be moved into their respective locations...
- standard_country_list() is only called from System module, so it should be moved to
system.countries.inc
, or similar - standard_language_list() is called in a number of locations, so it should be moved into Drupal\Core\Language\Language as a public static function. Possibly Language::getStandardLanguages()
Follow-up Issues
#1862202: Objectify the language system
#2004506: Move standard_country_list() to Drupal\Core\Locale\Country
#1730834: Remove language() indirection/static cache, consistently use 'language' (factory) service on container
#2010542: Remove variable 'language_types' in favor of configuration object system.language.types
#1550866: Remove obsolete drupal_language_initialize()
Comment | File | Size | Author |
---|---|---|---|
#54 | 1845034-language-core-service-54.patch | 16.55 KB | Gábor Hojtsy |
#49 | 1845034-language-core-service-49.patch | 16.54 KB | Cameron Tod |
#37 | 1845034.patch | 16.53 KB | RobLoach |
#35 | 1845034.patch | 16.47 KB | RobLoach |
#25 | 1845034.patch | 18.4 KB | RobLoach |
Comments
Comment #1
nick_schuch CreditAttribution: nick_schuch commentedInitial patch.
- standard.inc is now locale.inc
- standard_language_list() is now Language::getStandardLanguageList()
Comment #3
sandykadam CreditAttribution: sandykadam commented@nick_schuch,
Your above patch is good but missing static definition in function. I have applied the changes in patch, it should now work.
Comment #5
sandykadam CreditAttribution: sandykadam commented#3: 1845034-2-added-missing-static-defination.patch queued for re-testing.
Comment #7
sandykadam CreditAttribution: sandykadam commentedAgain made some minor changes for incorrect locale.inc include & static definition changes.
Comment #8
sandykadam CreditAttribution: sandykadam commentedre-submitting patch file
Comment #10
sandykadam CreditAttribution: sandykadam commented#8: 1845034-8-resolved-static-defination-and-include-changes.patch queued for re-testing.
Comment #12
sandykadam CreditAttribution: sandykadam commented#8: 1845034-8-resolved-static-defination-and-include-changes.patch queued for re-testing.
Comment #14
nick_schuch CreditAttribution: nick_schuch commentedLooks like the last 2 patches weren't saved in UTF-8.
Comment #16
nick_schuch CreditAttribution: nick_schuch commentedLooks like the last 2 patches weren't saved in UTF-8.
Comment #17
nick_schuch CreditAttribution: nick_schuch commentedComment #19
nick_schuch CreditAttribution: nick_schuch commented#17: 1845034-14-resolved-static-defination-and-include-changes.patch queued for re-testing.
Comment #21
sandykadam CreditAttribution: sandykadam commented#17: 1845034-14-resolved-static-defination-and-include-changes.patch queued for re-testing.
Comment #23
RobLoachComment #25
RobLoachComment #26
RobLoachComment #27
plachI think the original idea behind standard.inc was avoiding to load unnecessary code on every request. The current patch defeats this purpose. What about just making standard.inc an autoloadable
Standard
class?Comment #28
RobLoachStatic functions won't cause any performance issues. The places where
Language::getStandardLanguages()
is used, the class is already being used too, so the function is already loaded. The Languages list should live in Language, since it's a list of languages.You're right the countries could benefit from this though! Where do you think it should go?
Comment #29
plachThat function is used very rarely: loading it on every request seems a waste of memory to me.
Well,
Language
is singular, hence for consistency I'd go forDrupal\Core\Utility\Country
although I recall there was a non irrelevant discussion behind thestandard.inc
name (not surprisingly :), which in D7 wasiso.inc
. Not sure whether we want to retain the "standard" terminology somewhere, possibily in the package name.Comment #30
Gábor HojtsyYeah, core/lib/Drupal/Core/Language/Language.php is loaded on every page request on every single Drupal 8 site. I'm not sure of the diff of memory use with the added method, if we want to make our code cleaner and take this (small?) penalty, then so be it. Just be aware of it.
Comment #31
plachIf we want to have clean code we can use the
Language
package: this is what it's there for :)Sticking every language-related bit of code in the
Language
class does not look particularly clean to my eyes. In fact #1862202: Objectify the language system is moving thelanguage_list()
implementation into theLanguageManager
class. If we don't want a dedicated class, then I'd say the language manger is the place.Comment #32
RobLoachLanguage list to move into Drupal\Core\Language\LanguageManager
Countries to move into Drupal\Core\Utility\Country
Sounds reasonable to me. Any objections?
Comment #33
YesCT CreditAttribution: YesCT commentedsounds reasonable to me also.
patch will be like #25 but to those locations proposed in #32. (not quite a novice task, so tagging medium. anyone can tackle making a patch for this)
I see this patch is also updating the script too. #1068840: core/includes/standard.inc contains inaccurate country data good.
Comment #34
plachNo strong ones.
Comment #35
RobLoachLet's move standard_country_list() to a follow up:
#2004506: Move standard_country_list() to Drupal\Core\Locale\Country
Comment #36
plachLanguageManager::getLanguageList()
will be name of the method used to retrieve the installed language list (see #1862202: Objectify the language system). I'd suggest to rename it toLanguageManager::getStandardLanguageList()
. Aside from that looks good to me, thanks.Comment #37
RobLoachComment #38
plachRTBC If green. Thanks!
Comment #39
plach@YestCT:
Can you direct someone to the follow-up Rob linked in #35? It should be fairly easy.
Comment #40
plach@RobLoach:
One last-minute thought: should we instantiate the
LanguageManager
instead of using a static method? Right now we are hardcoding the implementation instead of relying on the DIC.Comment #42
plach#37: 1845034.patch queued for re-testing.
Comment #44
RobLoachComment #45
RobLoach#37: 1845034.patch queued for re-testing.
Comment #47
plach#37: 1845034.patch queued for re-testing.
Now git should be back.
Comment #49
Cameron Tod CreditAttribution: Cameron Tod commentedThis should fix the fails, but I think we should probably move this into the DIC as suggested in #40.
Will work on it.
Comment #50
RobLoachIf this goes green, then RTBC! A couple of great follow ups to this to getting this in the DIC and general clean up are:
Comment #51
Cameron Tod CreditAttribution: Cameron Tod commentedComment #52
plach+1 on RTBC
Comment #53
alexpottNeeds a reroll
Comment #54
Gábor HojtsyThe fail to apply was just around the use XZY; lines in install.core.inc. Easy reroll :) Should only be committed after green of course.
Comment #55
alexpottCommitted 56f4362 and pushed to 8.x. Thanks!
Comment #56
Gábor HojtsyWoot, thanks!
Comment #57
plachAdded a change notice for this:
https://drupal.org/node/2019333
Comment #58
larowlanUpdating tags
Comment #59.0
(not verified) CreditAttribution: commentedadding list of followups to summary