[FEATURE] Introduce an Environment API class 60/55960/6
authorBenni Mack <benni@typo3.org>
Thu, 1 Mar 2018 07:07:22 +0000 (08:07 +0100)
committerSusanne Moog <susanne.moog@typo3.org>
Wed, 7 Mar 2018 10:01:01 +0000 (11:01 +0100)
commitf10f551b51e71ab9cb1f9ea4e41cdfe2da4d8fd5
tree683d1b3af0775fd7d03154192e5e6ba28d0d47e0
parent64f8e8d2416c3b36a24d19bc7b19239b4309bdc9
[FEATURE] Introduce an Environment API class

A new class Environment is added, which is initialized right at the very
beginning of any TYPO3-based request.

The class contains a static list of properties commonly used throughout the
core to access paths, constants or global variables. The class also contains
methods that are relevant for ALL kind of PHP requests, CLI and web requests.

In order to avoid constants, and global variables, this is centralized in one
place, which allows to "re-define" values for testing purposes, making functional
tests a lot simpler.

This would better be stored in a dependency injection container and injected
as dependency/parameter into the respective classes that need the information.
We're not at that point to use dependency injection for every class, therefore
this class provides a static interface as a long-term interim solution.

Additionally, it adds a new functionality, basically finally allowing to move
code outside of the PATH_site constant with a proper API.

If the environment variable "TYPO3_PATH_APP" is set, this acts as a root path
for the project, which can be the same as PATH_site, or (usually) one level
up.
All typical new composer-based installations have this folder structure set up
automatically. Non-composer mode installations can set this environment variable
to make TYPO3 aware of non-public-accessable folders.

The following changes apply (with further patches):
- When TYPO3_PATH_APP is set, all logs / sessions / cache files are moved into $PROJECT_ROOT/var/.
- Same applies to typo3conf/l10n/, effectively moving this into a semi-writable
place, the same place where logs should be placed.
- LocalConfiguration.php, PackageStates.php and AdditionalConfiguration.php
  are now located at $PROJECT_ROOT/config/

The folder typo3conf then only contains code related to extensions.

The long-term goal until 9 LTS is that TYPO3 Core does not use any constants
anymore, which have been superseded by this class right now.

Resolves: #84153
Releases: master
Change-Id: I7ca35f752493d7e0d1c21c83a9ffbfb6a40eb463
Reviewed-on: https://review.typo3.org/55960
Reviewed-by: Benjamin Franzke <bfr@qbus.de>
Tested-by: Benjamin Franzke <bfr@qbus.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Tested-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
16 files changed:
typo3/sysext/backend/Classes/Backend/ToolbarItems/SystemInformationToolbarItem.php
typo3/sysext/core/Classes/Core/Bootstrap.php
typo3/sysext/core/Classes/Core/Environment.php [new file with mode: 0644]
typo3/sysext/core/Classes/Core/SystemEnvironmentBuilder.php
typo3/sysext/core/Classes/Package/PackageManager.php
typo3/sysext/core/Documentation/Changelog/master/Feature-84153-IntroduceAGenericEnvironmentClass.rst [new file with mode: 0644]
typo3/sysext/core/ext_localconf.php
typo3/sysext/extensionmanager/Classes/Command/ExtensionCommandController.php
typo3/sysext/extensionmanager/Classes/Controller/AbstractModuleController.php
typo3/sysext/extensionmanager/Classes/Controller/ListController.php
typo3/sysext/extensionmanager/Classes/Controller/UploadExtensionFileController.php
typo3/sysext/extensionmanager/Classes/Utility/Connection/TerUtility.php
typo3/sysext/install/Classes/Controller/InstallerController.php
typo3/sysext/install/Classes/Controller/MaintenanceController.php
typo3/sysext/install/Classes/Controller/UpgradeController.php
typo3/sysext/install/Classes/Service/CoreUpdateService.php