‪TYPO3CMS  9.5
EnvironmentStatusReport.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
26 
32 {
38  public function ‪getStatus()
39  {
40  return $this->‪getStatusInternal(false);
41  }
42 
48  public function ‪getDetailedStatus()
49  {
50  return $this->‪getStatusInternal(true);
51  }
52 
57  protected function ‪getStatusInternal($verbose)
58  {
59  $statusMessageQueue = new ‪FlashMessageQueue('install');
60  foreach (GeneralUtility::makeInstance(Check::class)->‪getStatus() as $message) {
61  $statusMessageQueue->enqueue($message);
62  }
63  foreach (GeneralUtility::makeInstance(SetupCheck::class)->‪getStatus() as $message) {
64  $statusMessageQueue->enqueue($message);
65  }
66  foreach (GeneralUtility::makeInstance(DatabaseCheck::class)->‪getStatus() as $message) {
67  $statusMessageQueue->enqueue($message);
68  }
69  $reportStatusTypes = [
70  'error' => [],
71  'warning' => [],
72  'ok' => [],
73  'information' => [],
74  'notice' => [],
75  ];
76  foreach ($statusMessageQueue->toArray() as $message) {
77  switch ($message->getSeverity()) {
79  $reportStatusTypes['error'][] = $message;
80  break;
82  $reportStatusTypes['warning'][] = $message;
83  break;
85  $reportStatusTypes['ok'][] = $message;
86  break;
88  $reportStatusTypes['information'][] = $message;
89  break;
91  $reportStatusTypes['notice'][] = $message;
92  break;
93  }
94  }
95 
96  $statusArray = [];
97  foreach ($reportStatusTypes as $type => $statusObjects) {
98  $value = count($statusObjects);
99  $message = '';
100  if ($verbose) {
101  foreach ($statusObjects as $statusObject) {
102  $message .= '### ' . $statusObject->getTitle() . ': ' . $statusObject->getSeverity() . CRLF;
103  }
104  }
105 
106  if ($value > 0) {
107  $pathToXliff = 'LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf';
108  // Map information type to abbreviation which is used in \TYPO3\CMS\Reports\Status class
109  if ($type === 'information') {
110  $type = 'info';
111  }
112  if (!$verbose) {
113  $message = ‪$GLOBALS['LANG']->sL($pathToXliff . ':environment.status.message.' . $type);
114  }
115  $severity = constant('\TYPO3\CMS\Reports\Status::' . strtoupper($type));
116  $statusArray[] = GeneralUtility::makeInstance(
117  Status::class,
118  ‪$GLOBALS['LANG']->sL($pathToXliff . ':environment.status.title'),
119  sprintf(‪$GLOBALS['LANG']->sL($pathToXliff . ':environment.status.value'), $value),
120  $message,
121  $severity
122  );
123  }
124  }
125 
126  return $statusArray;
127  }
128 }
‪TYPO3\CMS\Install\Report\EnvironmentStatusReport\getStatusInternal
‪Status[] getStatusInternal($verbose)
Definition: EnvironmentStatusReport.php:57
‪TYPO3\CMS\Reports\StatusProviderInterface
Definition: StatusProviderInterface.php:21
‪TYPO3\CMS\Install\Report\EnvironmentStatusReport\getStatus
‪Status[] getStatus()
Definition: EnvironmentStatusReport.php:38
‪TYPO3\CMS\Install\Report
Definition: EnvironmentStatusReport.php:2
‪TYPO3\CMS\Install\Report\EnvironmentStatusReport
Definition: EnvironmentStatusReport.php:32
‪TYPO3\CMS\Reports\Status
Definition: Status.php:22
‪TYPO3\CMS\Core\Messaging\AbstractMessage\WARNING
‪const WARNING
Definition: AbstractMessage.php:28
‪TYPO3\CMS\Install\SystemEnvironment\DatabaseCheck
Definition: DatabaseCheck.php:32
‪TYPO3\CMS\Core\Messaging\AbstractMessage\OK
‪const OK
Definition: AbstractMessage.php:27
‪TYPO3\CMS\Core\Messaging\AbstractMessage\INFO
‪const INFO
Definition: AbstractMessage.php:26
‪TYPO3\CMS\Core\Messaging\FlashMessage
Definition: FlashMessage.php:22
‪TYPO3\CMS\Install\SystemEnvironment\Check
Definition: Check.php:51
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Install\SystemEnvironment\SetupCheck
Definition: SetupCheck.php:35
‪TYPO3\CMS\Core\Messaging\AbstractMessage\NOTICE
‪const NOTICE
Definition: AbstractMessage.php:25
‪TYPO3\CMS\Reports\ExtendedStatusProviderInterface
Definition: ExtendedStatusProviderInterface.php:21
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Core\Messaging\FlashMessageQueue
Definition: FlashMessageQueue.php:25
‪TYPO3\CMS\Core\Messaging\AbstractMessage\ERROR
‪const ERROR
Definition: AbstractMessage.php:29
‪TYPO3\CMS\Install\Report\EnvironmentStatusReport\getDetailedStatus
‪Status[] getDetailedStatus()
Definition: EnvironmentStatusReport.php:48