Skip to content
Snippets Groups Projects
Commit 5278a235 authored by Benni Mack's avatar Benni Mack Committed by Christian Kuhn
Browse files

[TASK] Show ordered PSR-15 middlewares in Configuration module

In order to find out what middlewares are called in which order,
the Configuration module now has an additional list of all
registered middlewares for "frontend" and "backend" stack.

Resolves: #83882
Releases: master
Change-Id: I99d8478bb07437efa65d292221ccdb03d5dd3161
Reviewed-on: https://review.typo3.org/55597


Reviewed-by: default avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: default avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 340f4eae
No related merge requests found
......@@ -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);
......
......@@ -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>
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment