Skip to content

Commit

Permalink
Merge branch '2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
robbieaverill committed May 25, 2018
2 parents cacf25f + 3c1055e commit 489f8c5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/DataFormatter/JSONDataFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ public function convertDataObjectToJSONObject(DataObjectInterface $obj, $fields
if ($this->customRelations && !in_array($relName, $this->customRelations)) {
continue;
}
if ($obj->$relName() && (!$obj->$relName()->exists() || !$obj->$relName()->canView())) {
continue;
}

$fieldName = $relName . 'ID';
$rel = $this->config()->api_base;
Expand Down Expand Up @@ -144,6 +147,9 @@ public function convertDataObjectToJSONObject(DataObjectInterface $obj, $fields
$innerParts = array();
$items = $obj->$relName();
foreach ($items as $item) {
if (!$item->canView()) {
continue;
}
$rel = $this->config()->api_base . $this->sanitiseClassName($relClass) . "/$item->ID";
$href = Director::absoluteURL($rel);
$innerParts[] = ArrayData::array_to_object(array(
Expand Down

0 comments on commit 489f8c5

Please sign in to comment.