/** * Expects a filter JSON array URL encoded */ function scenario_get() { if (!$this->get('filters')) { $this->response(NULL, 400); } else { // Decode the filters } if (!$this->get('id')) { $this->response(NULL, 400); } $scenario = new Scenario($this->get('id')); if ($scenario->exists()) { $scenario_array = $scenario->all_to_array(); foreach ($scenario_array as $key => $value) { $scenario_array[$key]['authors'] = $scenario->authors->all_to_single_array('name'); //$scenario_array[$key]['subtiers'] = $scenario->subtiers->all_to_single_array('name'); } $this->response($scenario_array, 200); // 200 being the HTTP response code } else { $this->response(array('error' => 'Scenario could not be found'), 404); } }