function testUnderscoreTransforming() { $map = ["first_name" => "FirstName", "email" => "Email", "id" => "ID", "created" => "Created", "class_name" => "ClassName", "last_edited" => "LastEdited"]; foreach ($map as $expected => $input) { $this->assertEquals($expected, ApiDataObject::to_underscore($input)); } }
function index() { $modelName = $this->request->param('Model'); $schema = array(); $underscoreFields = Config::inst()->get($modelName, 'underscoreFields'); foreach (singleton($modelName)->inheritedDatabaseFields() as $key => $value) { if ($underscoreFields) { $key = ApiDataObject::to_underscore($key); } $schema[$key] = $value; } return $this->sendData(["schema" => $schema]); }