[TASK] Streamline and optimize JavaScript in install tool
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / View / JsonView.php
index b42bb3b..8be2af1 100644 (file)
@@ -75,9 +75,45 @@ class JsonView extends AbstractView
     public function transformStatusToArray(StatusInterface $status)
     {
         $arrayStatus = [];
-        $arrayStatus['severity'] = htmlspecialchars($status->getSeverity());
+        $arrayStatus['severity'] = $this->getSeverityAsNumber($status->getSeverity());
         $arrayStatus['title'] = htmlspecialchars($status->getTitle());
         $arrayStatus['message'] = htmlspecialchars($status->getMessage());
         return $arrayStatus;
     }
+
+    /**
+     * Return the corresponding integer value for given severity string
+     *
+     * @param string $severity
+     *
+     * @return int
+     */
+    protected function getSeverityAsNumber($severity)
+    {
+        $number = -2;
+        switch (strtolower($severity)) {
+            case 'loading':
+                $number = -3;
+                break;
+            case 'notice':
+                $number = -2;
+                break;
+            case 'info':
+                $number = -1;
+                break;
+            case 'ok':
+            case 'success':
+                $number = 0;
+                break;
+            case 'warning':
+                $number = 1;
+                break;
+            case 'error':
+            case 'danger':
+            case 'fatal':
+                $number = 2;
+                break;
+        }
+        return $number;
+    }
 }