‪TYPO3CMS  ‪main
ExtensionComposerStatus.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Psr\Http\Message\ServerRequestInterface;
28 
35 {
36  public function ‪__construct(
37  protected readonly ‪ComposerDeficitDetector $composerDeficitDetector,
38  protected readonly ‪UriBuilder $uriBuilder
39  ) {}
40 
41  public function ‪getStatus(ServerRequestInterface $request = null): array
42  {
43  $status = [];
44  $extensionsWithComposerDeficit = $this->composerDeficitDetector->getExtensionsWithComposerDeficit();
45  $languageService = $this->‪getLanguageService();
46  $deficits = [
49  ];
50 
51  $queryParameters = [
52  'action' => 'list',
53  'controller' => 'ExtensionComposerStatus',
54  ];
55 
56  if ($request !== null) {
57  $queryParameters['returnUrl'] =
58  $request->getAttribute('normalizedParams')->getRequestUri();
59  }
60 
61  $dispatchAction = 'TYPO3.ModuleMenu.showModule';
62  $dispatchArgs = [
63  'tools_ExtensionmanagerExtensionmanager',
64  '&' . http_build_query($queryParameters),
65  ];
66 
67  foreach ($deficits as $key => $deficit) {
68  $message = '';
69  $extensionsToReport = count(array_filter($extensionsWithComposerDeficit, static function ($extensionInformation) use ($key) {
70  return $extensionInformation['deficit'] === $key;
71  }));
72 
73  if ($extensionsToReport) {
74  $title = $languageService->sL('LLL:EXT:extensionmanager/Resources/Private/Language/locallang.xlf:report.status.composerManifest.update');
75  $attributes = GeneralUtility::implodeAttributes([
76  'type' => 'button',
77  'title' => $title,
78  'class' => 'btn btn-link text-decoration-underline',
79  // relies on module 'TYPO3/CMS/Backend/ActionDispatcher'
80  'data-dispatch-action' => $dispatchAction,
81  'data-dispatch-args' => GeneralUtility::jsonEncodeForHtmlAttribute($dispatchArgs),
82  ], true);
83  $message = sprintf($languageService->sL('LLL:EXT:extensionmanager/Resources/Private/Language/locallang.xlf:report.status.composerManifest.' . $deficit . '.message'), $extensionsToReport)
84  . '<br /><button ' . $attributes . '>' . htmlspecialchars($title) . '</button>';
85  }
86 
87  $status[] = GeneralUtility::makeInstance(
88  ReportStatus::class,
89  $this->‪getLanguageService()->sL('LLL:EXT:extensionmanager/Resources/Private/Language/locallang.xlf:report.status.composerManifest.' . $deficit),
90  $this->‪getLanguageService()->sL($extensionsToReport ? 'LLL:EXT:reports/Resources/Private/Language/locallang_reports.xlf:status_checkFailed' : 'LLL:EXT:reports/Resources/Private/Language/locallang_reports.xlf:status_none'),
91  $message,
92  $extensionsToReport ? ContextualFeedbackSeverity::WARNING : ContextualFeedbackSeverity::OK
93  );
94  }
95 
96  return $status;
97  }
98 
99  public function ‪getLabel(): string
100  {
101  return 'Composer Manifest';
102  }
103 
105  {
106  return ‪$GLOBALS['LANG'];
107  }
108 }
‪TYPO3\CMS\Extensionmanager\Package\ComposerDeficitDetector
Definition: ComposerDeficitDetector.php:27
‪TYPO3\CMS\Extensionmanager\Package\ComposerDeficitDetector\EXTENSION_COMPOSER_MANIFEST_MISSING
‪const EXTENSION_COMPOSER_MANIFEST_MISSING
Definition: ComposerDeficitDetector.php:29
‪TYPO3\CMS\Extensionmanager\Report
Definition: ExtensionComposerStatus.php:18
‪TYPO3\CMS\Extensionmanager\Report\ExtensionComposerStatus\getStatus
‪getStatus(ServerRequestInterface $request=null)
Definition: ExtensionComposerStatus.php:41
‪TYPO3\CMS\Extensionmanager\Report\ExtensionComposerStatus\__construct
‪__construct(protected readonly ComposerDeficitDetector $composerDeficitDetector, protected readonly UriBuilder $uriBuilder)
Definition: ExtensionComposerStatus.php:36
‪TYPO3\CMS\Extensionmanager\Report\ExtensionComposerStatus
Definition: ExtensionComposerStatus.php:35
‪TYPO3\CMS\Extensionmanager\Report\ExtensionComposerStatus\getLanguageService
‪getLanguageService()
Definition: ExtensionComposerStatus.php:104
‪TYPO3\CMS\Core\Type\ContextualFeedbackSeverity
‪ContextualFeedbackSeverity
Definition: ContextualFeedbackSeverity.php:25
‪TYPO3\CMS\Core\Security\ContentSecurityPolicy\Reporting\ReportStatus
‪ReportStatus
Definition: ReportStatus.php:24
‪TYPO3\CMS\Extensionmanager\Package\ComposerDeficitDetector\EXTENSION_KEY_MISSING
‪const EXTENSION_KEY_MISSING
Definition: ComposerDeficitDetector.php:30
‪TYPO3\CMS\Reports\Status
Definition: Status.php:24
‪TYPO3\CMS\Backend\Routing\UriBuilder
Definition: UriBuilder.php:44
‪TYPO3\CMS\Extensionmanager\Report\ExtensionComposerStatus\getLabel
‪getLabel()
Definition: ExtensionComposerStatus.php:99
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:46
‪TYPO3\CMS\Reports\RequestAwareStatusProviderInterface
Definition: RequestAwareStatusProviderInterface.php:26
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52