diff --git a/typo3/sysext/lowlevel/Classes/Controller/ConfigurationController.php b/typo3/sysext/lowlevel/Classes/Controller/ConfigurationController.php index e983a2883d67b0d0d3863a9c4518f2a8192d0eef..90295e8172d9992e69ea3a2b2f459dd899822101 100644 --- a/typo3/sysext/lowlevel/Classes/Controller/ConfigurationController.php +++ b/typo3/sysext/lowlevel/Classes/Controller/ConfigurationController.php @@ -20,7 +20,12 @@ use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Backend\Routing\Router; use TYPO3\CMS\Backend\Template\ModuleTemplate; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; +use TYPO3\CMS\Core\Cache\Backend\NullBackend; +use TYPO3\CMS\Core\Cache\Frontend\PhpFrontend; +use TYPO3\CMS\Core\Http\MiddlewareStackResolver; use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Package\PackageManager; +use TYPO3\CMS\Core\Service\DependencyOrderingService; use TYPO3\CMS\Core\Utility\ArrayUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Fluid\View\StandaloneView; @@ -99,6 +104,10 @@ class ConfigurationController 'label' => 'routes', 'type' => 'routes', ], + 'httpMiddlewareStacks' => [ + 'label' => 'httpMiddlewareStacks', + 'type' => 'httpMiddlewareStacks', + ], ]; /** @@ -163,6 +172,7 @@ class ConfigurationController $moduleState['regexSearch'] = (bool)($postValues['regexSearch'] ?? $moduleState['regexSearch'] ?? false); // Prepare main array + $sortKeysByName = true; if ($selectedTreeDetails['type'] === 'global') { $globalArrayKey = $selectedTreeDetails['globalKey']; $renderArray = $GLOBALS[$globalArrayKey]; @@ -201,10 +211,33 @@ class ConfigurationController 'options' => $route->getOptions() ]; } + } elseif ($selectedTreeDetails['type'] === 'httpMiddlewareStacks') { + // Keep the order of the keys + $sortKeysByName = false; + // Fake a PHP frontend with a null backend to avoid PHP Opcache conflicts + // When using >requireOnce() multiple times in one request + $cache = GeneralUtility::makeInstance( + PhpFrontend::class, + 'middleware', + GeneralUtility::makeInstance(NullBackend::class, 'Production') + ); + $stackResolver = GeneralUtility::makeInstance( + MiddlewareStackResolver::class, + GeneralUtility::makeInstance(PackageManager::class), + GeneralUtility::makeInstance(DependencyOrderingService::class), + $cache + ); + $renderArray = []; + foreach (['frontend', 'backend'] as $stackName) { + // reversing the array allows the admin to read the stack from top to bottom + $renderArray[$stackName] = array_reverse($stackResolver->resolve($stackName)); + } } else { throw new \RuntimeException('Unknown array type "' . $selectedTreeDetails['type'] . '"', 1507845662); } - ArrayUtility::naturalKeySortRecursive($renderArray); + if ($sortKeysByName) { + ArrayUtility::naturalKeySortRecursive($renderArray); + } // Prepare array renderer class, apply search and expand / collapse states $arrayBrowser = GeneralUtility::makeInstance(ArrayBrowser::class); diff --git a/typo3/sysext/lowlevel/Resources/Private/Language/locallang.xlf b/typo3/sysext/lowlevel/Resources/Private/Language/locallang.xlf index ebfa1a77d0523eeb4fb906cf292e3c99ac973846..1b0a33f0f63249d3020eba98cbb258037b242354 100644 --- a/typo3/sysext/lowlevel/Resources/Private/Language/locallang.xlf +++ b/typo3/sysext/lowlevel/Resources/Private/Language/locallang.xlf @@ -30,6 +30,9 @@ <trans-unit id="routes"> <source>Backend Routes</source> </trans-unit> + <trans-unit id="httpMiddlewareStacks"> + <source>HTTP Middlewares (PSR-15)</source> + </trans-unit> <trans-unit id="t3services"> <source>$GLOBALS['T3_SERVICES'] (Registered Services)</source> </trans-unit>