TYPO3 CMS  TYPO3_8-7
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 
20 
25 {
31  public function getStatus()
32  {
33  return $this->getStatusInternal(false);
34  }
35 
41  public function getDetailedStatus()
42  {
43  return $this->getStatusInternal(true);
44  }
45 
51  protected function getStatusInternal($verbose)
52  {
53  $statusObjects = array_merge(
54  GeneralUtility::makeInstance(\TYPO3\CMS\Install\SystemEnvironment\Check::class)->getStatus(),
55  GeneralUtility::makeInstance(\TYPO3\CMS\Install\SystemEnvironment\SetupCheck::class)->getStatus(),
56  GeneralUtility::makeInstance(\TYPO3\CMS\Install\SystemEnvironment\DatabaseCheck::class)->getStatus()
57  );
58  $reportStatusTypes = [
59  'error' => [],
60  'warning' => [],
61  'ok' => [],
62  'information' => [],
63  'notice' => [],
64  ];
65 
67  foreach ($statusObjects as $statusObject) {
68  $severityIdentifier = $statusObject->getSeverity();
69  if (empty($severityIdentifier) || !is_array($reportStatusTypes[$severityIdentifier])) {
70  throw new \TYPO3\CMS\Install\Exception('Unknown reports severity type', 1362602560);
71  }
72  $reportStatusTypes[$severityIdentifier][] = $statusObject;
73  }
74 
75  $statusArray = [];
76  foreach ($reportStatusTypes as $type => $statusObjects) {
77  $value = count($statusObjects);
78  $message = '';
79  if ($verbose) {
80  foreach ($statusObjects as $statusObject) {
81  $message .= '### ' . $statusObject->getTitle() . ': ' . $statusObject->getSeverity() . CRLF;
82  }
83  }
84 
85  if ($value > 0) {
86  $pathToXliff = 'LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf';
87  // Map information type to abbreviation which is used in \TYPO3\CMS\Reports\Status class
88  if ($type === 'information') {
89  $type = 'info';
90  }
91  if (!$verbose) {
92  $message = $GLOBALS['LANG']->sL($pathToXliff . ':environment.status.message.' . $type);
93  }
94  $severity = constant('\TYPO3\CMS\Reports\Status::' . strtoupper($type));
95  $statusArray[] = GeneralUtility::makeInstance(
96  \TYPO3\CMS\Reports\Status::class,
97  $GLOBALS['LANG']->sL($pathToXliff . ':environment.status.title'),
98  sprintf($GLOBALS['LANG']->sL($pathToXliff . ':environment.status.value'), $value),
99  $message,
100  $severity
101  );
102  }
103  }
104 
105  return $statusArray;
106  }
107 }
static makeInstance($className,... $constructorArguments)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']