Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow objects to specify a subset of fields when exported by having a…

… toFilteredMap instead of just Map and SS3 updates
  • Loading branch information...
commit 80e7b1b1ce3e0577e7a7247b74eaeced7fe67d0d 1 parent ea9ed1c
Marcus Nyeholt authored
View
4 code/controllers/WebServiceController.php
@@ -66,7 +66,7 @@ public function init() {
}
}
- public function handleRequest(SS_HTTPRequest $request) {
+ public function handleRequest(SS_HTTPRequest $request, DataModel $model) {
try {
$this->pushCurrent();
if ((!Member::currentUserID() && !self::$allow_public_access) || $request->requestVar('token')) {
@@ -88,7 +88,7 @@ public function handleRequest(SS_HTTPRequest $request) {
} else if (!self::$allow_public_access) {
throw new WebServiceException(403, "Invalid request");
}
- $response = parent::handleRequest($request);
+ $response = parent::handleRequest($request, $model);
if (self::has_curr()) {
$this->popCurrent();
View
3  code/serialisers/DataObjectJsonConverter.php
@@ -9,6 +9,9 @@
class DataObjectJsonConverter {
public function convert(DataObject $object) {
+ if ($object->hasMethod('toFilteredMap')) {
+ return Convert::raw2json($object->toFilteredMap());
+ }
return Convert::raw2json($object->toMap());
}
}
View
4 code/serialisers/DataObjectSetJsonConverter.php
@@ -12,7 +12,9 @@ public function convert($set) {
$ret = new stdClass();
$ret->items = array();
foreach ($set as $item) {
- if (method_exists($item, 'toMap')) {
+ if ($item instanceof Object && $item->hasMethod('toFilteredMap')) {
+ $ret->items[] = $item->toFilteredMap();
+ } else if (method_exists($item, 'toMap')) {
$ret->items[] = $item->toMap();
} else {
$ret->items[] = $item;
View
1  code/services/DummyWebService.php
@@ -24,7 +24,6 @@ public function webEnabledMethods() {
}
public function myMethod($param) {
-
return array(
'SomeParam' => 'Goes here',
'Boolean' => true,
Please sign in to comment.
Something went wrong with that request. Please try again.