Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 1627 → Rev 1628

/trunk/jrest/JRest.php
154,9 → 154,14
if (class_exists($resource_class)) {
$service = new $resource_class($this->config);
if (method_exists($service,'updateElement')) { // Update element
// TODO : a voir le retour ...
if ($service->updateElement($this->uid, $pairs)) {
$this->created();
$ret_value = false;
try {
// TODO : a voir le retour ...
$ret_value = $service->updateElement($this->uid, $pairs);
if($ret_value) $this->created();
else $this->badRequest();
} catch (Exception $e) {
$this->badRequest($e);
}
}
}
206,8 → 211,13
if (class_exists($resource_class)) {
$service = new $resource_class($this->config);
if (method_exists($service,'createElement')) { // Create a new element
if ($service->createElement($pairs)) {
$this->created();
$ret_value = false;
try {
$ret_value = $service->createElement($pairs);
if($ret_value) $this->created();
else $this->badRequest();
} catch (Exception $e) {
$this->badRequest($e);
}
}
}
254,8 → 264,9
/**
* Send a HTTP 400 response header.
*/
private function badRequest() {
private function badRequest(Exception $e = NULL) {
header('HTTP/1.0 400 Bad Request');
if($e) echo $e->getMessage();
}
 
/**