[ 'debug' => true, 'loginRateLimit' => 10000, ], 'FE' => [ 'debug' => true, 'loginRateLimit' => 10000, ], 'GFX' => [ 'processor_colorspace' => 'RGB', 'processor_path' => '/usr/bin/', 'processor_path_lzw' => '/usr/bin/', ], 'SYS' => [ 'devIPmask' => '*', 'displayErrors' => 1, 'systemLogLevel' => 0, 'exceptionalErrors' => 12290, 'errorHandlerErrors' => E_ALL & ~( E_STRICT | E_NOTICE | E_WARNING | E_COMPILE_WARNING | E_COMPILE_ERROR | E_CORE_WARNING | E_CORE_ERROR | E_PARSE | E_ERROR ), ], ]; /** * This is needed to override all mail settings instead of merging them. * * @var array */ protected array $mailConfig = [ 'transport' => 'smtp', 'transport_smtp_server' => 'mailpit:1025' ]; public function initialize(array $configuration = []): void { $this->addContextToSitename(); $this->addContextConfiguration($configuration); if (Environment::getContext() == 'Development') { $this->addDebugConfiguration(); } $this->addFurtherConfigurationFiles(); } protected function addContextToSitename(): void { $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] .= ' - ' . Environment::getContext(); } protected function addDebugConfiguration(): void { $GLOBALS['TYPO3_CONF_VARS'] = $this->arrayMergeRecursive( $GLOBALS['TYPO3_CONF_VARS'], $this->developConfig ); $layoutRootPaths = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['layoutRootPaths'] ?: []; $partialRootPaths = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['partialRootPaths'] ?: []; $templateRootPaths = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['templateRootPaths'] ?: []; $GLOBALS['TYPO3_CONF_VARS']['MAIL'] = $this->mailConfig; if (!empty($layoutRootPaths)) { $GLOBALS['TYPO3_CONF_VARS']['MAIL']['layoutRootPaths'] = $layoutRootPaths; } if (!empty($partialRootPaths)) { $GLOBALS['TYPO3_CONF_VARS']['MAIL']['partialRootPaths'] = $partialRootPaths; } if (!empty($templateRootPaths)) { $GLOBALS['TYPO3_CONF_VARS']['MAIL']['templateRootPaths'] = $templateRootPaths; } } protected function addContextConfiguration(array $configuration): void { $context = (string)Environment::getContext(); if (isset($configuration[$context]) && is_array($configuration[$context])) { $GLOBALS['TYPO3_CONF_VARS'] = $this->arrayMergeRecursive( $GLOBALS['TYPO3_CONF_VARS'], $configuration[$context] ); } } /** * Loads additional configuration two levels up relative to instance * or relative to ADDITIONAL_CONFIG_FILE configuration */ protected function addFurtherConfigurationFiles(): void { $paths = [ Environment::getPublicPath() . '/../../../AdditionalConfiguration.php', Environment::getPublicPath() . '/' . ($_SERVER['ADDITIONAL_CONFIG_FILE'] ?? time() . '.php'), ]; foreach ($paths as $path) { $path = realpath($path); if ($path && @file_exists($path)) { /** @noinspection */ require_once $path; } } } protected function arrayMergeRecursive(array $array1, array $array2): array { $merged = $array1; foreach ($array2 as $key => $value) { if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) { $merged[$key] = $this->arrayMergeRecursive($merged[$key], $value); } elseif (is_numeric($key)) { if (!in_array($value, $merged)) { $merged[] = $value; } } else { $merged[$key] = $value; } } return $merged; } }