Skip to content

Commit 38114db

Browse files
committed
Add backend report for TYPO3 v14
1 parent ff53a86 commit 38114db

2 files changed

Lines changed: 80 additions & 0 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Cundd\Rest\Controller;
6+
7+
use Cundd\Rest\Documentation\HandlerDescriptor;
8+
use Cundd\Rest\Exception\InvalidConfigurationException;
9+
use Psr\Http\Message\ResponseInterface;
10+
use Psr\Http\Message\ServerRequestInterface;
11+
use TYPO3\CMS\Backend\Attribute\AsController;
12+
use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
13+
use TYPO3\CMS\Core\Site\SiteFinder;
14+
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
15+
16+
#[AsController]
17+
final class ReportController extends ActionController
18+
{
19+
public function __construct(
20+
private readonly ModuleTemplateFactory $moduleTemplateFactory,
21+
private readonly SiteFinder $siteFinder,
22+
private readonly HandlerDescriptor $handlerDescriptor,
23+
) {
24+
}
25+
26+
public function handleRequest(
27+
ServerRequestInterface $request,
28+
): ResponseInterface {
29+
$moduleTemplate = $this->moduleTemplateFactory->create($request);
30+
31+
$information = [];
32+
foreach ($this->siteFinder->getAllSites() as $site) {
33+
$siteConfiguration = null;
34+
35+
try {
36+
$siteConfiguration = $this->handlerDescriptor->getInformation($site);
37+
} catch (InvalidConfigurationException $e) {
38+
}
39+
40+
if ($siteConfiguration) {
41+
$information = array_merge(
42+
$information,
43+
$siteConfiguration
44+
);
45+
}
46+
}
47+
48+
$moduleTemplate->assign('information', $information);
49+
50+
return $moduleTemplate->renderResponse('HandlerReport');
51+
}
52+
}

Configuration/Backend/Modules.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Cundd\Rest\Controller\ReportController;
6+
use TYPO3\CMS\Core\Information\Typo3Version;
7+
8+
if (14 == (new Typo3Version())->getMajorVersion()) {
9+
return [
10+
'system_reports_rest' => [
11+
'parent' => 'system_reports',
12+
'access' => 'admin',
13+
'path' => '/module/system/reports/rest',
14+
'iconIdentifier' => 'module-reports',
15+
'labels' => [
16+
'title' => 'LLL:EXT:rest/Resources/Private/Language/locallang_db.xlf:reports.handler.title',
17+
'description' => 'LLL:EXT:rest/Resources/Private/Language/locallang_db.xlf:reports.handler.description',
18+
],
19+
'routes' => [
20+
'_default' => [
21+
'target' => ReportController::class . '::handleRequest',
22+
],
23+
],
24+
],
25+
];
26+
} else {
27+
return [];
28+
}

0 commit comments

Comments
 (0)