1 | <?php |
||
29 | class IncidentsController extends AppController { |
||
30 | public $uses = array("Incident", "Notification"); |
||
31 | |||
32 | 1 | public function create() { |
|
33 | 1 | $bugReport = $this->request->input('json_decode', true); |
|
34 | 1 | $result = $this->Incidents->createIncidentFromBugReport($bugReport); |
|
35 | 1 | if (count($result) > 0 |
|
36 | 1 | && !in_array(false, $result) |
|
37 | ) { |
||
38 | $response = array( |
||
39 | 1 | "success" => true, |
|
40 | 1 | "message" => "Thank you for your submission", |
|
41 | 1 | "incident_id" => $result, // Return a list of incident ids. |
|
42 | ); |
||
43 | } else { |
||
44 | $response = array( |
||
45 | 1 | "success" => false, |
|
46 | "message" => "There was a problem with your submission.", |
||
47 | ); |
||
48 | } |
||
49 | 1 | $this->autoRender = false; |
|
50 | 1 | $this->response->body(json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); |
|
51 | 1 | return $this->response; |
|
52 | } |
||
53 | |||
54 | 1 | public function json($id) { |
|
55 | 1 | if (!$id) { |
|
56 | throw new NotFoundException(__('Invalid Incident')); |
||
57 | } |
||
58 | |||
59 | 1 | $this->Incidents->recursive = -1; |
|
60 | 1 | $incident = $this->Incidents->findById($id)->all()->first(); |
|
61 | 1 | if (!$incident) { |
|
62 | throw new NotFoundException(__('Invalid Incident')); |
||
63 | } |
||
64 | |||
65 | 1 | $incident['full_report'] = |
|
66 | 1 | json_decode($incident['full_report'], true); |
|
67 | 1 | $incident['stacktrace'] = |
|
68 | 1 | json_decode($incident['stacktrace'], true); |
|
69 | |||
70 | 1 | $this->autoRender = false; |
|
71 | 1 | $this->response->body(json_encode($incident, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); |
|
72 | 1 | return $this->response; |
|
73 | } |
||
74 | |||
75 | 1 | public function view($incidentId) { |
|
92 | } |
||
93 |