[!!!][TASK] Rewrite install tool
[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 'information' => array(),
50 'notice' => array(),
51 );
52
53 /** @var $statusObject \TYPO3\CMS\Install\Status\AbstractStatus */
54 foreach ($statusObjects as $statusObject) {
55 $severityIdentifier = $statusObject->getSeverity();
56 if (empty($severityIdentifier) || !is_array($reportStatusTypes[$severityIdentifier])) {
57 throw new \TYPO3\CMS\Install\Exception('Unknown reports severity type', 1362602560);
58 }
59 $reportStatusTypes[$severityIdentifier][] = $statusObject;
60 }
61
62 $statusArray = array();
63 foreach ($reportStatusTypes as $type => $statusObjects) {
64 $value = count($statusObjects);
65 if ($value > 0) {
66 $pathToXliff = 'LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf';
67 // Map information type to abbreviation which is used in \TYPO3\CMS\Reports\Status class
68 if ($type === 'information') {
69 $type = 'info';
70 }
71 $message = $GLOBALS['LANG']->sL($pathToXliff . ':environment.status.message.' . $type);
72 $severity = constant('\TYPO3\CMS\Reports\Status::' . strtoupper($type));
73 $statusArray[] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
74 'TYPO3\\CMS\\Reports\\Status',
75 $GLOBALS['LANG']->sL($pathToXliff . ':environment.status.title'),
76 sprintf($GLOBALS['LANG']->sL($pathToXliff . ':environment.status.value'), $value),
77 $message,
78 $severity
79 );
80 }
81 }
82
83 return $statusArray;
84 }
85 }
86
87 ?>