summaryrefslogtreecommitdiffstats
path: root/core/modules/rest/src/Plugin/rest/resource/EntityResource.php
diff options
context:
space:
mode:
authorNathaniel Catchpole2014-12-19 10:12:31 +0000
committerNathaniel Catchpole2014-12-19 10:12:31 +0000
commitda33162efdd121343bfbccf503d30fc59a4ec9b3 (patch)
treec19166b7598fc3338ac0acf99ed23bd558a86678 /core/modules/rest/src/Plugin/rest/resource/EntityResource.php
parent37e7d708c97c8648af7eb22290bff9e69cecaf77 (diff)
Issue #2368807 by yched: Remove special support for NULL values in FieldItemList
Diffstat (limited to 'core/modules/rest/src/Plugin/rest/resource/EntityResource.php')
-rw-r--r--core/modules/rest/src/Plugin/rest/resource/EntityResource.php31
1 files changed, 15 insertions, 16 deletions
diff --git a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php
index c58ff1a..c861239 100644
--- a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php
+++ b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php
@@ -134,22 +134,21 @@ class EntityResource extends ResourceBase {
}
// Overwrite the received properties.
- foreach ($entity as $field_name => $field) {
- if (isset($entity->{$field_name})) {
- // It is not possible to set the language to NULL as it is automatically
- // re-initialized. As it must not be empty, skip it if it is.
- // @todo: Use the langcode entity key when available. See
- // https://drupal.org/node/2143729.
- if ($field_name == 'langcode' && $field->isEmpty()) {
- continue;
- }
- if ($field->isEmpty() && !$original_entity->get($field_name)->access('delete')) {
- throw new AccessDeniedHttpException(String::format('Access denied on deleting field ', array('@field' => $field_name)));
- }
- $original_entity->set($field_name, $field->getValue());
- if (!$original_entity->get($field_name)->access('update')) {
- throw new AccessDeniedHttpException(String::format('Access denied on updating field ', array('@field' => $field_name)));
- }
+ foreach ($entity->_restPatchFields as $field_name) {
+ $field = $entity->get($field_name);
+ // It is not possible to set the language to NULL as it is automatically
+ // re-initialized. As it must not be empty, skip it if it is.
+ // @todo: Use the langcode entity key when available. See
+ // https://drupal.org/node/2143729.
+ if ($field_name == 'langcode' && $field->isEmpty()) {
+ continue;
+ }
+ if ($field->isEmpty() && !$original_entity->get($field_name)->access('delete')) {
+ throw new AccessDeniedHttpException(String::format('Access denied on deleting field @field.', array('@field' => $field_name)));
+ }
+ $original_entity->set($field_name, $field->getValue());
+ if (!$original_entity->get($field_name)->access('update')) {
+ throw new AccessDeniedHttpException(String::format('Access denied on updating field @field.', array('@field' => $field_name)));
}
}