Project

General

Profile

Actions

Feature #94995

open

Expose environment object through DI

Added by Larry Garfield about 3 years ago. Updated almost 3 years ago.

Status:
Under Review
Priority:
Should have
Category:
-
Start date:
2021-08-25
Due date:
% Done:

0%

Estimated time:
PHP Version:
8.1
Tags:
Complexity:
Sprint Focus:

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.

Related issues 1 (0 open1 closed)

Blocked by TYPO3 Core - Task #96612: Update to latest PHP ParserClosedLarry Garfield2022-01-21

Actions
Actions

Also available in: Atom PDF