/**
  * @inheritdoc
  */
 protected function getFieldsForObj($do)
 {
     $fields = parent::getFieldsForObj($do);
     // Make sure our ID field is the first one.
     $fields = array('ID' => $fields['ID']) + $fields;
     return $fields;
 }
 /**
  * Converts either the given HTTP Body into an array
  * (based on the DataFormatter instance), or returns
  * the POST variables.
  * Automatically filters out certain critical fields
  * that shouldn't be set by the client (e.g. ID).
  *
  * @param DataObject $obj
  * @param DataFormatter $formatter
  * @return DataObject The passed object
  */
 protected function updateDataObject($obj, $formatter)
 {
     // if neither an http body nor POST data is present, return error
     $body = $this->request->getBody();
     if (!$body && !$this->request->postVars()) {
         $this->getResponse()->setStatusCode(204);
         // No Content
         return 'No Content';
     }
     if (!empty($body)) {
         $data = $formatter->convertStringToArray($body);
     } else {
         // assume application/x-www-form-urlencoded which is automatically parsed by PHP
         $data = $this->request->postVars();
     }
     // @todo Disallow editing of certain keys in database
     $data = array_diff_key($data, array('ID', 'Created'));
     $apiAccess = singleton($this->urlParams['ClassName'])->stat('api_access');
     if (is_array($apiAccess) && isset($apiAccess['edit'])) {
         $data = array_intersect_key($data, array_combine($apiAccess['edit'], $apiAccess['edit']));
     }
     $obj->update($data);
     $obj->write();
     return $obj;
 }
 public function convertDataObject(DataObjectInterface $obj, $fields = null)
 {
     parent::convertDataObject($obj, $fields);
 }