TYPO3 CMS  TYPO3_6-2
JsonView.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Install\View;
3 
19 use TYPO3\CMS\Install\Status\Exception as StatusException;
20 
24 class JsonView extends AbstractView {
25 
29  public function render() {
30  $renderedData = $this->variables;
31  if (isset($renderedData['status']) && is_array($renderedData['status'])) {
32  try {
33  $renderedData['status'] = $this->transformStatusMessagesToArray($renderedData['status']);
34  } catch (StatusException $e) {
35  $renderedData['status'] = array(array(
36  'severity' => 'error',
37  'title' => htmlspecialchars($e->getMessage())
38  ));
39  }
40  }
41 
42  return $renderedData;
43  }
44 
52  protected function transformStatusMessagesToArray(array $statusArray = array()) {
53  $result = array();
54  foreach ($statusArray as $status) {
55  if (!$status instanceof StatusInterface) {
56  throw new StatusException (
57  'Object must implement StatusInterface',
58  1381059600
59  );
60  }
61  $result[] = $this->transformStatusToArray($status);
62  }
63  return $result;
64  }
65 
73  public function transformStatusToArray(StatusInterface $status) {
74  $arrayStatus = array();
75  $arrayStatus['severity'] = htmlspecialchars($status->getSeverity());
76  $arrayStatus['title'] = htmlspecialchars($status->getTitle());
77  $arrayStatus['message'] = htmlspecialchars($status->getMessage());
78  return $arrayStatus;
79  }
80 
81 }
transformStatusMessagesToArray(array $statusArray=array())
Definition: JsonView.php:52
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren&#39;t numeric.
transformStatusToArray(StatusInterface $status)
Definition: JsonView.php:73