mirror of
https://github.com/silverstripe/silverstripe-restfulserver
synced 2024-10-22 14:05:58 +02:00
Merge pull request #56 from catalyst/sanitise-json-classnames
Sanitise json classnames
This commit is contained in:
commit
bb000254af
@ -108,11 +108,11 @@ class JSONDataFormatter extends DataFormatter
|
|||||||
}
|
}
|
||||||
|
|
||||||
$fieldName = $relName . 'ID';
|
$fieldName = $relName . 'ID';
|
||||||
if ($obj->$fieldName) {
|
$rel = $this->config()->api_base;
|
||||||
$href = Director::absoluteURL($this->config()->api_base . "$relClass/" . $obj->$fieldName);
|
$rel .= $obj->$fieldName
|
||||||
} else {
|
? $this->sanitiseClassName($relClass) . '/' . $obj->$fieldName
|
||||||
$href = Director::absoluteURL($this->config()->api_base . "$className/$id/$relName");
|
: $this->sanitiseClassName($className) . "/$id/$relName";
|
||||||
}
|
$href = Director::absoluteURL($rel);
|
||||||
$serobj->$relName = ArrayData::array_to_object(array(
|
$serobj->$relName = ArrayData::array_to_object(array(
|
||||||
"className" => $relClass,
|
"className" => $relClass,
|
||||||
"href" => "$href.json",
|
"href" => "$href.json",
|
||||||
@ -140,8 +140,8 @@ class JSONDataFormatter extends DataFormatter
|
|||||||
$innerParts = array();
|
$innerParts = array();
|
||||||
$items = $obj->$relName();
|
$items = $obj->$relName();
|
||||||
foreach ($items as $item) {
|
foreach ($items as $item) {
|
||||||
//$href = Director::absoluteURL($this->config()->api_base . "$className/$id/$relName/$item->ID");
|
$rel = $this->config()->api_base . $this->sanitiseClassName($relClass) . "/$item->ID";
|
||||||
$href = Director::absoluteURL($this->config()->api_base . "$relClass/$item->ID");
|
$href = Director::absoluteURL($rel);
|
||||||
$innerParts[] = ArrayData::array_to_object(array(
|
$innerParts[] = ArrayData::array_to_object(array(
|
||||||
"className" => $relClass,
|
"className" => $relClass,
|
||||||
"href" => "$href.json",
|
"href" => "$href.json",
|
||||||
|
Loading…
Reference in New Issue
Block a user