summaryrefslogtreecommitdiffstats
path: root/core/modules/hal/tests/src/Functional/EntityResource/HalEntityNormalizationTrait.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/hal/tests/src/Functional/EntityResource/HalEntityNormalizationTrait.php')
-rw-r--r--core/modules/hal/tests/src/Functional/EntityResource/HalEntityNormalizationTrait.php18
1 files changed, 18 insertions, 0 deletions
diff --git a/core/modules/hal/tests/src/Functional/EntityResource/HalEntityNormalizationTrait.php b/core/modules/hal/tests/src/Functional/EntityResource/HalEntityNormalizationTrait.php
index eb01944..b64de67 100644
--- a/core/modules/hal/tests/src/Functional/EntityResource/HalEntityNormalizationTrait.php
+++ b/core/modules/hal/tests/src/Functional/EntityResource/HalEntityNormalizationTrait.php
@@ -73,6 +73,24 @@ trait HalEntityNormalizationTrait {
/**
* {@inheritdoc}
*/
+ protected function removeFieldsFromNormalization(array $normalization, $field_names) {
+ $normalization = parent::removeFieldsFromNormalization($normalization, $field_names);
+ foreach ($field_names as $field_name) {
+ $relation_url = Url::fromUri('base:rest/relation/' . static::$entityTypeId . '/' . $this->entity->bundle() . '/' . $field_name)
+ ->setAbsolute(TRUE)
+ ->toString();
+ $normalization['_links'] = array_diff_key($normalization['_links'], [$relation_url => TRUE]);
+ if (isset($normalization['_embedded'])) {
+ $normalization['_embedded'] = array_diff_key($normalization['_embedded'], [$relation_url => TRUE]);
+ }
+ }
+
+ return array_diff_key($normalization, array_flip($field_names));
+ }
+
+ /**
+ * {@inheritdoc}
+ */
protected function assertNormalizationEdgeCases($method, Url $url, array $request_options) {
// \Drupal\hal\Normalizer\EntityNormalizer::denormalize(): entity
// types with bundles MUST send their bundle field to be denormalizable.