diff --git a/core/modules/hal/tests/src/Functional/EntityResource/EntityTest/EntityTestHalJsonInternalPropertyNormalizerTest.php b/core/modules/hal/tests/src/Functional/EntityResource/EntityTest/EntityTestHalJsonInternalPropertyNormalizerTest.php index 0ba00bd21f..ce02ca6b13 100644 --- a/core/modules/hal/tests/src/Functional/EntityResource/EntityTest/EntityTestHalJsonInternalPropertyNormalizerTest.php +++ b/core/modules/hal/tests/src/Functional/EntityResource/EntityTest/EntityTestHalJsonInternalPropertyNormalizerTest.php @@ -8,7 +8,7 @@ use Drupal\Tests\rest\Functional\AnonResourceTestTrait; /** - * Test that internal properties are not exposed in REST. + * Test that internal properties are not exposed in the 'hal_json' format. * * @group hal */ diff --git a/core/modules/rest/tests/src/Functional/EntityResource/EntityTest/EntityTestJsonInternalPropertyNormalizerTest.php b/core/modules/rest/tests/src/Functional/EntityResource/EntityTest/EntityTestJsonInternalPropertyNormalizerTest.php index 9b7f1bcc91..7c64e3fdac 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/EntityTest/EntityTestJsonInternalPropertyNormalizerTest.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/EntityTest/EntityTestJsonInternalPropertyNormalizerTest.php @@ -7,7 +7,7 @@ use Drupal\Tests\rest\Functional\AnonResourceTestTrait; /** - * Test that internal properties are not exposed in REST. + * Test that internal properties are not exposed in the 'json' format. * * @group rest */ diff --git a/core/modules/rest/tests/src/Functional/EntityResource/EntityTest/EntityTestResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/EntityTest/EntityTestResourceTestBase.php index da75f1064e..5ca1f7e44c 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/EntityTest/EntityTestResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/EntityTest/EntityTestResourceTestBase.php @@ -55,14 +55,15 @@ protected function setUpAuthorization($method) { protected function createEntity() { // Set flag so that internal field 'internal_string_field' is created. // @see \entity_test_entity_base_field_info() - $this->container->get('state')->set('entity_test.test_internal', TRUE); + $this->container->get('state')->set('entity_test.internal_field', TRUE); \Drupal::entityDefinitionUpdateManager()->applyUpdates(); $entity_test = EntityTest::create([ 'name' => 'Llama', 'type' => 'entity_test', // Set a value for the internal field to confirm that it will not be - // returned in normalization. @see \entity_test_entity_base_field_info(). + // returned in normalization. + // @see \entity_test_entity_base_field_info(). 'internal_string_field' => [ 'value' => 'value to be internal', ], diff --git a/core/modules/serialization/src/Normalizer/ContentEntityNormalizer.php b/core/modules/serialization/src/Normalizer/ContentEntityNormalizer.php index 96ef4040ee..6ac8927df6 100644 --- a/core/modules/serialization/src/Normalizer/ContentEntityNormalizer.php +++ b/core/modules/serialization/src/Normalizer/ContentEntityNormalizer.php @@ -1,6 +1,7 @@ getValue(); - if (is_object($value) && $object instanceof PrimitiveInterface) { - return $object->getCastedValue(); - } - return $value; + return $object->getValue(); } } diff --git a/core/modules/serialization/tests/src/Unit/Normalizer/TimestampItemNormalizerTest.php b/core/modules/serialization/tests/src/Unit/Normalizer/TimestampItemNormalizerTest.php index 8945d3f43e..c4e351424a 100644 --- a/core/modules/serialization/tests/src/Unit/Normalizer/TimestampItemNormalizerTest.php +++ b/core/modules/serialization/tests/src/Unit/Normalizer/TimestampItemNormalizerTest.php @@ -79,14 +79,14 @@ public function testNormalize() { $timestamp_item->getIterator() ->willReturn(new \ArrayIterator(['value' => 1478422920])); - $non_internal_property = $this->getTypedDataProperty(FALSE); + $value_property = $this->getTypedDataProperty(FALSE); $timestamp_item->getProperties(TRUE) - ->willReturn(['value' => $non_internal_property]) + ->willReturn(['value' => $value_property]) ->shouldBeCalled(); $serializer_prophecy = $this->prophesize(Serializer::class); - $serializer_prophecy->normalize($non_internal_property, NULL, []) + $serializer_prophecy->normalize($value_property, NULL, []) ->willReturn(1478422920) ->shouldBeCalled(); diff --git a/core/modules/system/tests/modules/entity_test/config/schema/entity_test.data_types.schema.yml b/core/modules/system/tests/modules/entity_test/config/schema/entity_test.data_types.schema.yml index 5c3bddf2b3..cebaf03905 100644 --- a/core/modules/system/tests/modules/entity_test/config/schema/entity_test.data_types.schema.yml +++ b/core/modules/system/tests/modules/entity_test/config/schema/entity_test.data_types.schema.yml @@ -1,4 +1,4 @@ -# Schema for the configuration of the internal property field type. +# Schema for the configuration of the 'internal property test' field type. field.storage_settings.internal_property_test: type: field.storage_settings.string diff --git a/core/modules/system/tests/modules/entity_test/entity_test.module b/core/modules/system/tests/modules/entity_test/entity_test.module index e0f62cc4dc..025cb5fc2f 100644 --- a/core/modules/system/tests/modules/entity_test/entity_test.module +++ b/core/modules/system/tests/modules/entity_test/entity_test.module @@ -109,9 +109,9 @@ function entity_test_entity_type_alter(array &$entity_types) { function entity_test_entity_base_field_info(EntityTypeInterface $entity_type) { $fields = []; - if ($entity_type->id() === 'entity_test' && \Drupal::state()->get('entity_test.test_internal')) { + if ($entity_type->id() === 'entity_test' && \Drupal::state()->get('entity_test.internal_field')) { $fields['internal_string_field'] = BaseFieldDefinition::create('string') - ->setLabel('Internal') + ->setLabel('Internal field') ->setInternal(TRUE); } if ($entity_type->id() == 'entity_test_mulrev' && \Drupal::state()->get('entity_test.field_test_item')) { diff --git a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/InternalPropertyTestFieldItem.php b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/InternalPropertyTestFieldItem.php index b981339efa..2bc8154cf9 100644 --- a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/InternalPropertyTestFieldItem.php +++ b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/InternalPropertyTestFieldItem.php @@ -30,13 +30,13 @@ public static function propertyDefinitions(FieldStorageDefinitionInterface $fiel // Add a computed property that is non-internal. $properties['non_internal_value'] = DataDefinition::create('string') - ->setLabel(new TranslatableMarkup('Computed string, non-internal')) + ->setLabel(new TranslatableMarkup('Computed string, non-internal property')) ->setComputed(TRUE) ->setClass(ComputedString::class) ->setInternal(FALSE); // Add a computed property that is internal. $properties['internal_value'] = DataDefinition::create('string') - ->setLabel(new TranslatableMarkup('Computed string, internal')) + ->setLabel(new TranslatableMarkup('Computed string, internal property')) ->setComputed(TRUE) ->setClass(ComputedString::class); return $properties;