[BUGFIX] System environment report always says warning
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Report / EnvironmentStatusReport.php
1 <?php
2 namespace TYPO3\CMS\Install\Report;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 /**
28 * Provides an environment status report
29 *
30 * @author Christian Kuhn <lolli@schwarzbu.ch>
31 */
32 class EnvironmentStatusReport implements \TYPO3\CMS\Reports\StatusProviderInterface {
33
34 /**
35 * Compile environment status report
36 *
37 * @throws \TYPO3\CMS\Install\Exception
38 * @return array<\TYPO3\CMS\Reports\Status>
39 */
40 public function getStatus() {
41 /** @var $statusCheck \TYPO3\CMS\Install\SystemEnvironment\Check */
42 $statusCheck = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Install\\SystemEnvironment\\Check');
43 $statusObjects = $statusCheck->getStatus();
44
45 $reportStatusTypes = array(
46 'ERROR' => array(),
47 'WARNING' => array(),
48 'OK' => array(),
49 'INFO' => array(),
50 'NOTICE' => array(),
51 );
52
53 foreach ($statusObjects as $statusObject) {
54 $className = get_class($statusObject);
55 // Uppercase last part of class name, without last 6 chars:
56 // TYPO3\CMS\Install\SystemEnvironment\ErrorStatus -> ERROR
57 $severityIdentifier = strtoupper(substr(array_pop(explode('\\', $className)), 0, -6));
58 if (!is_array($reportStatusTypes[$severityIdentifier])) {
59 throw new \TYPO3\CMS\Install\Exception('Unknown reports severity type', 1362602560);
60 }
61 $reportStatusTypes[$severityIdentifier][] = $statusObject;
62 }
63
64 $statusArray = array();
65 foreach ($reportStatusTypes as $type => $statusObjects) {
66 $value = count($statusObjects);
67 if ($value > 0) {
68 $pathToXliff = 'LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf';
69 $message = $GLOBALS['LANG']->sL($pathToXliff . ':environment.status.message.' . strtolower($type));
70 $severity = constant('\TYPO3\CMS\Reports\Status::' . $type);
71 $statusArray[] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
72 'TYPO3\\CMS\\Reports\\Status',
73 $GLOBALS['LANG']->sL($pathToXliff . ':environment.status.title'),
74 sprintf($GLOBALS['LANG']->sL($pathToXliff . ':environment.status.value'), $value),
75 $message,
76 $severity
77 );
78 }
79 }
80
81 return $statusArray;
82 }
83 }
84
85 ?>