Skip to content

Commit

Permalink
Fix multiple relationships and remove duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaohutai committed Sep 6, 2017
1 parent bf6e0f8 commit d87382f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Action/FetchAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,20 @@ protected function fetchIncludes($includes, $results, $parameters)
if (is_array($results)) {
foreach ($results as $key => $item) {
//Loop through all relationships
foreach ($item->relation[$include] as $related) {
$included[$key] = $this->storeRelatedContent($parameters, $include, $related);
foreach ($item->getRelation($include) as $related) {
$included[] = $this->storeRelatedContent($parameters, $include, $related);
}
}
//Must be a single content type
} elseif ($results instanceof Content) {
//Loop through all relationships
foreach ($results->getRelation($include) as $key => $related) {
$included[$key] = $this->storeRelatedContent($parameters, $include, $related);
foreach ($results->getRelation($include) as $related) {
$included[] = $this->storeRelatedContent($parameters, $include, $related);
}
}

}

$included = array_unique($included, SORT_REGULAR);
return array_values($included);
}

Expand Down

0 comments on commit d87382f

Please sign in to comment.