You are here

public static function Data::merge in Drupal 9

Same name and namespace in other branches
  1. 8 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 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 154

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()));
}