/** * @param string $ps_table Target table * @param array $pa_data Test data. Format of a single record is similar to the JSON format used in the * Web Service API, only that it's a PHP array, obviously. In fact, we use the same code to insert the data. * * @see http://docs.collectiveaccess.org/wiki/Web_Service_API#Creating_new_records * @see https://gist.githubusercontent.com/skeidel/3871797/raw/item_request.json * @return int the primary key of the newly created record */ protected function addTestRecord($ps_table, $pa_data) { if (!is_array($pa_data)) { return false; } $o_itemservice = new ItemService($this->opo_request, $ps_table); $va_return = $o_itemservice->addItem($ps_table, $pa_data); if (!$va_return) { $this->assertTrue(false, 'Inserting test data failed. API errors are: ' . join(' ', $o_itemservice->getErrors())); } $this->opa_record_map[$ps_table][] = $vn_return = array_shift($va_return); return $vn_return; }
public function __call($ps_table, $pa_args) { $vo_service = new ItemService($this->request, $ps_table); $va_content = $vo_service->dispatch(); if (intval($this->request->getParameter("pretty", pInteger)) > 0) { $this->view->setVar("pretty_print", true); } if ($vo_service->hasErrors()) { $this->view->setVar("errors", $vo_service->getErrors()); $this->render("json_error.php"); } else { $this->view->setVar("content", $va_content); $this->render("json.php"); } }