‪TYPO3CMS  ‪main
EnvironmentStatusReport.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
29 
35 {
41  public function ‪getStatus(): array
42  {
43  if (‪Environment::isCli()) {
44  return [];
45  }
46  return $this->‪getStatusInternal(false);
47  }
48 
49  public function ‪getLabel(): string
50  {
51  return 'system';
52  }
53 
59  public function ‪getDetailedStatus()
60  {
61  if (‪Environment::isCli()) {
62  return [];
63  }
64  return $this->‪getStatusInternal(true);
65  }
66 
71  protected function ‪getStatusInternal($verbose)
72  {
73  $statusMessageQueue = new ‪FlashMessageQueue('install');
74  foreach (GeneralUtility::makeInstance(Check::class)->‪getStatus() as $message) {
75  $statusMessageQueue->enqueue($message);
76  }
77  foreach (GeneralUtility::makeInstance(SetupCheck::class)->‪getStatus() as $message) {
78  $statusMessageQueue->enqueue($message);
79  }
80  foreach (GeneralUtility::makeInstance(DatabaseCheck::class)->‪getStatus() as $message) {
81  $statusMessageQueue->enqueue($message);
82  }
83  $reportStatusTypes = [
84  'error' => [],
85  'warning' => [],
86  'ok' => [],
87  'information' => [],
88  'notice' => [],
89  ];
90  foreach ($statusMessageQueue->toArray() as $message) {
91  switch ($message->getSeverity()) {
92  case ContextualFeedbackSeverity::ERROR:
93  $reportStatusTypes['error'][] = $message;
94  break;
95  case ContextualFeedbackSeverity::WARNING:
96  $reportStatusTypes['warning'][] = $message;
97  break;
98  case ContextualFeedbackSeverity::OK:
99  $reportStatusTypes['ok'][] = $message;
100  break;
101  case ContextualFeedbackSeverity::INFO:
102  $reportStatusTypes['information'][] = $message;
103  break;
104  case ContextualFeedbackSeverity::NOTICE:
105  $reportStatusTypes['notice'][] = $message;
106  break;
107  }
108  }
109 
110  $statusArray = [];
111  foreach ($reportStatusTypes as $type => $statusObjects) {
112  $value = count($statusObjects);
113  $message = '';
114  if ($verbose) {
115  foreach ($statusObjects as $statusObject) {
116  $message .= '### ' . $statusObject->getTitle() . ': ' . $statusObject->getSeverity()->value . CRLF;
117  }
118  }
119 
120  if ($value > 0) {
121  $pathToXliff = 'LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf';
122  // Map information type to enums which is used in \TYPO3\CMS\Core\Type\ContextualFeedbackSeverity
123  if ($type === 'information') {
124  $type = 'info';
125  }
126  if (!$verbose) {
127  $message = $this->‪getLanguageService()->sL($pathToXliff . ':environment.status.message.' . $type);
128  }
129  $severity = constant('\TYPO3\CMS\Core\Type\ContextualFeedbackSeverity::' . strtoupper($type));
130  $statusArray[] = GeneralUtility::makeInstance(
131  Status::class,
132  $this->‪getLanguageService()->sL($pathToXliff . ':environment.status.title'),
133  sprintf($this->‪getLanguageService()->sL($pathToXliff . ':environment.status.value'), $value),
134  $message,
135  $severity
136  );
137  }
138  }
139 
140  return $statusArray;
141  }
142 
144  {
145  return ‪$GLOBALS['LANG'] ?? null;
146  }
147 }
‪TYPO3\CMS\Install\Report\EnvironmentStatusReport\getStatusInternal
‪Status[] getStatusInternal($verbose)
Definition: EnvironmentStatusReport.php:71
‪TYPO3\CMS\Reports\StatusProviderInterface
Definition: StatusProviderInterface.php:22
‪TYPO3\CMS\Install\Report\EnvironmentStatusReport\getStatus
‪Status[] getStatus()
Definition: EnvironmentStatusReport.php:41
‪TYPO3\CMS\Install\Report
Definition: EnvironmentStatusReport.php:16
‪TYPO3\CMS\Install\Report\EnvironmentStatusReport\getLabel
‪getLabel()
Definition: EnvironmentStatusReport.php:49
‪TYPO3\CMS\Install\Report\EnvironmentStatusReport\getLanguageService
‪getLanguageService()
Definition: EnvironmentStatusReport.php:143
‪TYPO3\CMS\Install\Report\EnvironmentStatusReport
Definition: EnvironmentStatusReport.php:35
‪TYPO3\CMS\Core\Type\ContextualFeedbackSeverity
‪ContextualFeedbackSeverity
Definition: ContextualFeedbackSeverity.php:25
‪TYPO3\CMS\Reports\Status
Definition: Status.php:24
‪TYPO3\CMS\Core\Core\Environment\isCli
‪static isCli()
Definition: Environment.php:145
‪TYPO3\CMS\Install\SystemEnvironment\DatabaseCheck
‪TYPO3\CMS\Install\SystemEnvironment\Check
Definition: Check.php:45
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:41
‪TYPO3\CMS\Install\SystemEnvironment\SetupCheck
Definition: SetupCheck.php:38
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:46
‪TYPO3\CMS\Reports\ExtendedStatusProviderInterface
Definition: ExtendedStatusProviderInterface.php:22
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Core\Messaging\FlashMessageQueue
Definition: FlashMessageQueue.php:29
‪TYPO3\CMS\Install\Report\EnvironmentStatusReport\getDetailedStatus
‪Status[] getDetailedStatus()
Definition: EnvironmentStatusReport.php:59