You are here

protected function JsonapiParse::flattenIncluded in JSON:API Include 8

Flatten included.

Parameters

array|mixed $resource: The resource.

Return value

array The result.

1 call to JsonapiParse::flattenIncluded()
JsonapiParse::resolveData in src/JsonapiParse.php
Resolve data.

File

src/JsonapiParse.php, line 99

Class

JsonapiParse
Class JsonapiParse.

Namespace

Drupal\jsonapi_include

Code

protected function flattenIncluded($resource) {
  if (isset($this->included[$resource['type']][$resource['id']])) {
    $object = $this
      ->resolveAttributes($this->included[$resource['type']][$resource['id']]);
    if (isset($resource['meta'])) {
      $object['meta'] = $resource['meta'];
    }
  }
  else {
    $object = $resource;
  }
  $result = $this
    ->resolveRelationships($object);
  return $result;
}