diff --git a/core/modules/hal/src/Normalizer/FileEntityNormalizer.php b/core/modules/hal/src/Normalizer/FileEntityNormalizer.php index 56fb38f..d2cf4e7 100644 --- a/core/modules/hal/src/Normalizer/FileEntityNormalizer.php +++ b/core/modules/hal/src/Normalizer/FileEntityNormalizer.php @@ -59,6 +59,7 @@ public function normalize($entity, $format = NULL, array $context = []) { * {@inheritdoc} */ public function denormalize($data, $class, $format = NULL, array $context = []) { + if (isset($data['uri'])) { $file_data = (string) $this->httpClient->get($data['uri'][0]['value'])->getBody(); $path = 'temporary://' . drupal_basename($data['uri'][0]['value']); @@ -67,6 +68,7 @@ public function denormalize($data, $class, $format = NULL, array $context = []) return $this->entityManager->getStorage('file')->create($data); } $data['uri'] = [['value' => $data['uri']]]; + } return parent::denormalize($data, $class, $format, $context); } diff --git a/core/modules/hal/tests/src/Functional/EntityResource/File/FileHalJsonAnonTest.php b/core/modules/hal/tests/src/Functional/EntityResource/File/FileHalJsonAnonTest.php index 9351fef..cfead8c 100644 --- a/core/modules/hal/tests/src/Functional/EntityResource/File/FileHalJsonAnonTest.php +++ b/core/modules/hal/tests/src/Functional/EntityResource/File/FileHalJsonAnonTest.php @@ -87,11 +87,6 @@ protected function getNormalizedPostEntity() { 'href' => $this->baseUrl . '/rest/type/file/file', ], ], - 'uri' => [ - [ - 'value' => file_create_url($this->entity->getFileUri()), - ], - ], ]; } diff --git a/core/modules/rest/tests/src/Functional/EntityResource/File/FileResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/File/FileResourceTestBase.php index 1815dc7..56546a8 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/File/FileResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/File/FileResourceTestBase.php @@ -30,6 +30,9 @@ * {@inheritdoc} */ protected static $patchProtectedFieldNames = [ + 'uri', + 'filemime', + 'filesize', 'status', 'changed', ];