User tests: Successful: Unsuccessful:
Pull Request for Issue comment #21289 (comment).
Introduces a language factory.
Question which comes up here is if the factory needs to do some caching? Because every createLanguage call in the factory actually loads the languages from scratch.
Browse around in the back end.
All is working.
All is working.
Similar as the rest of the factory and service provider classes.
| Status | New | ⇒ | Pending | 
| Category | ⇒ | Libraries | 
| Labels | 
                                        Added: 
?
 | 
    ||
probably will need a factory that supports singleton storage
You mean basically the logic which is now in Language::getInstance?
Right.
I have tested this item 
I have tested this item 
| Status | Pending | ⇒ | Ready to Commit | 
Ready to Commit after two successful tests.
I have tested this item 
I played around for some time, but this is not "covering" all possibilities ;-)
| Status | Ready to Commit | ⇒ | Fixed in Code Base | 
| Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-09-13 13:58:33 | 
| Closed_By | ⇒ | laoneo | |
| Labels | 
                                        Added: 
?
 | 
    ||
You're going to need some kind of caching support, probably will need a factory that supports singleton storage.
This is a case of the
getInstancemethod having more business logic than just creating a singleton of a class instance. In this case, it creates singletons for each language. And because theLanguageclass is environmentally aware (i.e. each instance has its own record of loaded translations), this isn't something that is just easily phased out.The
Languageclass absolutely should not be aware of or care about this singleton storage. But, as an overall application, the CMS absolutely does care about it.