function Data::merge

Same name in other branches
  1. 8.9.x core/modules/jsonapi/src/JsonApiResource/Data.php \Drupal\jsonapi\JsonApiResource\Data::merge()
  2. 10 core/modules/jsonapi/src/JsonApiResource/Data.php \Drupal\jsonapi\JsonApiResource\Data::merge()
  3. 11.x core/modules/jsonapi/src/JsonApiResource/Data.php \Drupal\jsonapi\JsonApiResource\Data::merge()

Returns a new Data object containing the entities of $this and $other.

Parameters

\Drupal\jsonapi\JsonApiResource\Data $a: A Data object to be merged.

\Drupal\jsonapi\JsonApiResource\Data $b: A Data object to be merged.

Return value

static A new merged Data object.

File

core/modules/jsonapi/src/JsonApiResource/Data.php, line 156

Class

Data
Represents the `data` and `included` objects of a top-level object.

Namespace

Drupal\jsonapi\JsonApiResource

Code

public static function merge(Data $a, Data $b) {
    return new static(array_merge($a->toArray(), $b->toArray()));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.