[TASK] Re-work/simplify copyright header in PHP files - Part 2
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Report / EnvironmentStatusReport.php
1 <?php
2 namespace TYPO3\CMS\Install\Report;
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
17 /**
18 * Provides an environment status report
19 *
20 * @author Christian Kuhn <lolli@schwarzbu.ch>
21 */
22 class EnvironmentStatusReport implements \TYPO3\CMS\Reports\StatusProviderInterface {
23
24 /**
25 * Compile environment status report
26 *
27 * @throws \TYPO3\CMS\Install\Exception
28 * @return array<\TYPO3\CMS\Reports\Status>
29 */
30 public function getStatus() {
31 /** @var $statusCheck \TYPO3\CMS\Install\SystemEnvironment\Check */
32 $statusCheck = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Install\\SystemEnvironment\\Check');
33 $statusObjects = $statusCheck->getStatus();
34
35 $reportStatusTypes = array(
36 'error' => array(),
37 'warning' => array(),
38 'ok' => array(),
39 'information' => array(),
40 'notice' => array(),
41 );
42
43 /** @var $statusObject \TYPO3\CMS\Install\Status\AbstractStatus */
44 foreach ($statusObjects as $statusObject) {
45 $severityIdentifier = $statusObject->getSeverity();
46 if (empty($severityIdentifier) || !is_array($reportStatusTypes[$severityIdentifier])) {
47 throw new \TYPO3\CMS\Install\Exception('Unknown reports severity type', 1362602560);
48 }
49 $reportStatusTypes[$severityIdentifier][] = $statusObject;
50 }
51
52 $statusArray = array();
53 foreach ($reportStatusTypes as $type => $statusObjects) {
54 $value = count($statusObjects);
55 if ($value > 0) {
56 $pathToXliff = 'LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf';
57 // Map information type to abbreviation which is used in \TYPO3\CMS\Reports\Status class
58 if ($type === 'information') {
59 $type = 'info';
60 }
61 $message = $GLOBALS['LANG']->sL($pathToXliff . ':environment.status.message.' . $type);
62 $severity = constant('\TYPO3\CMS\Reports\Status::' . strtoupper($type));
63 $statusArray[] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
64 'TYPO3\\CMS\\Reports\\Status',
65 $GLOBALS['LANG']->sL($pathToXliff . ':environment.status.title'),
66 sprintf($GLOBALS['LANG']->sL($pathToXliff . ':environment.status.value'), $value),
67 $message,
68 $severity
69 );
70 }
71 }
72
73 return $statusArray;
74 }
75 }