protected static function ResourceResponseTestTrait::mergeOmittedObjects in Drupal 8
Same name and namespace in other branches
- 9 core/modules/jsonapi/tests/src/Functional/ResourceResponseTestTrait.php \Drupal\Tests\jsonapi\Functional\ResourceResponseTestTrait::mergeOmittedObjects()
Merges the links of two omitted objects and returns a new omitted object.
Parameters
array $a: The first omitted object.
array $b: The second omitted object.
Return value
mixed A new, merged omitted object.
1 call to ResourceResponseTestTrait::mergeOmittedObjects()
- ResourceResponseTestTrait::addOmittedObject in core/
modules/ jsonapi/ tests/ src/ Functional/ ResourceResponseTestTrait.php - Add the omitted object to the document or merges it if one already exists.
File
- core/
modules/ jsonapi/ tests/ src/ Functional/ ResourceResponseTestTrait.php, line 619
Class
- ResourceResponseTestTrait
- Utility methods for handling resource responses.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
protected static function mergeOmittedObjects(array $a, array $b) {
$merged['detail'] = 'Some resources have been omitted because of insufficient authorization.';
$merged['links']['help']['href'] = 'https://www.drupal.org/docs/8/modules/json-api/filtering#filters-access-control';
$a_links = array_diff_key($a['links'], array_flip([
'help',
]));
$b_links = array_diff_key($b['links'], array_flip([
'help',
]));
foreach (array_merge(array_values($a_links), array_values($b_links)) as $link) {
$merged['links'][$link['href'] . $link['meta']['detail']] = $link;
}
static::resetOmittedLinkKeys($merged);
return $merged;
}