#94995Expose environment object through DI
Description
The Environment static class currently has a lot of useful information, but being static it’s bad for testability.
Solution, which will require PHP 8.1 and thus TYPO3 v12:
- Make all properties of the Environment class public and readonly.
- Make the initialize() static method just instantiate a singleton instance of Environment that is tracked internally.
- Have the constructor do whatever pre-processing and lookup is necessary (like computing some of the derived strings.)
- Change all the static methods to access the instance object and just return the appropriate property.
- Wire the Environment object into the DI system. (This will be the trickiest part; have to look up where it’s initialized right now.)
- Services can now get Environment injected, and just read public properties off of it as they need.
- Deprecate (either via documentation, code, or both) using the static methods.
- Remove the static methods in v13, leaving behind a readonly struct class in DI for anyone to use as needed, or trivially override for testing.