‪TYPO3CMS  10.4
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;
26 use ‪TYPO3\CMS\Reports\Status as ReportStatus;
27 
34 {
39 
43  protected ‪$uriBuilder;
44 
46  {
47  $this->composerDeficitDetector = ‪$composerDeficitDetector ?? GeneralUtility::makeInstance(ComposerDeficitDetector::class);
48  $this->uriBuilder = ‪$uriBuilder ?? GeneralUtility::makeInstance(UriBuilder::class);
49  }
50 
51  public function ‪getStatus(ServerRequestInterface $request = null): array
52  {
53  $status = [];
54  $extensionsWithComposerDeficit = $this->composerDeficitDetector->getExtensionsWithComposerDeficit();
55  $languageService = $this->‪getLanguageService();
56  $languageService->includeLLFile('EXT:extensionmanager/Resources/Private/Language/locallang.xlf');
57  $labelPrefix = 'report.status.composerManifest.';
58  $deficits = [
61  ];
62 
63  $queryParameters = [
64  'tx_extensionmanager_tools_extensionmanagerextensionmanager' => [
65  'action' => 'list',
66  'controller' => 'ExtensionComposerStatus',
67  ]
68  ];
69 
70  if ($request !== null) {
71  $queryParameters['tx_extensionmanager_tools_extensionmanagerextensionmanager']['returnUrl'] =
72  $request->getAttribute('normalizedParams')->getRequestUri();
73  }
74 
75  $dispatchAction = 'TYPO3.ModuleMenu.showModule';
76  $dispatchArgs = [
77  'tools_ExtensionmanagerExtensionmanager',
78  '&' . http_build_query($queryParameters)
79  ];
80 
81  foreach ($deficits as $key => $deficit) {
82  $message = '';
83  $extensionsToReport = count(array_filter($extensionsWithComposerDeficit, static function ($extensionDeficit) use ($key) {
84  return $extensionDeficit === $key;
85  }));
86 
87  if ($extensionsToReport) {
88  $linkTitle = $languageService->getLL($labelPrefix . 'update');
89  $linkAttributes = GeneralUtility::implodeAttributes([
90  'href' => '#',
91  'title' => $linkTitle,
92  'class' => 'text-decoration-underline',
93  // relies on module 'TYPO3/CMS/Backend/ActionDispatcher'
94  'data-dispatch-action' => $dispatchAction,
95  'data-dispatch-args' => GeneralUtility::jsonEncodeForHtmlAttribute($dispatchArgs),
96  ], true);
97  $message = sprintf($languageService->getLL($labelPrefix . $deficit . '.message'), $extensionsToReport)
98  . '<br /><a ' . $linkAttributes . '>' . htmlspecialchars($linkTitle) . '</a>';
99  }
100 
101  $status[] = GeneralUtility::makeInstance(
102  ReportStatus::class,
103  $this->‪getLanguageService()->getLL($labelPrefix . $deficit),
104  $this->‪getLanguageService()->getLL($extensionsToReport ? 'status_checkFailed' : 'status_none'),
105  $message,
106  $extensionsToReport ? ReportStatus::WARNING : ReportStatus::OK
107  );
108  }
109 
110  return $status;
111  }
112 
113  protected function ‪getLanguageService(): ‪LanguageService
114  {
115  return ‪$GLOBALS['LANG'];
116  }
117 }
‪TYPO3\CMS\Extensionmanager\Report
Definition: ExtensionComposerStatus.php:18
‪TYPO3\CMS\Extensionmanager\Report\ExtensionComposerStatus\getStatus
‪getStatus(ServerRequestInterface $request=null)
Definition: ExtensionComposerStatus.php:49
‪TYPO3\CMS\Extensionmanager\Report\ExtensionComposerStatus
Definition: ExtensionComposerStatus.php:34
‪TYPO3\CMS\Core\Package\ComposerDeficitDetector
Definition: ComposerDeficitDetector.php:29
‪TYPO3\CMS\Extensionmanager\Report\ExtensionComposerStatus\getLanguageService
‪getLanguageService()
Definition: ExtensionComposerStatus.php:111
‪TYPO3\CMS\Reports\StatusProviderInterface\getStatus
‪array getStatus()
‪TYPO3\CMS\Reports\Status
Definition: Status.php:24
‪TYPO3\CMS\Core\Package\ComposerDeficitDetector\EXTENSION_KEY_MISSING
‪const EXTENSION_KEY_MISSING
Definition: ComposerDeficitDetector.php:32
‪TYPO3\CMS\Backend\Routing\UriBuilder
Definition: UriBuilder.php:38
‪TYPO3\CMS\Extensionmanager\Report\ExtensionComposerStatus\$uriBuilder
‪UriBuilder $uriBuilder
Definition: ExtensionComposerStatus.php:41
‪TYPO3\CMS\Core\Package\ComposerDeficitDetector\EXTENSION_COMPOSER_MANIFEST_MISSING
‪const EXTENSION_COMPOSER_MANIFEST_MISSING
Definition: ComposerDeficitDetector.php:31
‪TYPO3\CMS\Extensionmanager\Report\ExtensionComposerStatus\__construct
‪__construct(ComposerDeficitDetector $composerDeficitDetector=null, UriBuilder $uriBuilder=null)
Definition: ExtensionComposerStatus.php:43
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:42
‪TYPO3\CMS\Reports\RequestAwareStatusProviderInterface
Definition: RequestAwareStatusProviderInterface.php:26
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Extensionmanager\Report\ExtensionComposerStatus\$composerDeficitDetector
‪ComposerDeficitDetector $composerDeficitDetector
Definition: ExtensionComposerStatus.php:37