resourceTypeRepository = $resource_type_repository; } /** * {@inheritdoc} */ public function normalize($entity, $format = NULL, array $context = []) { $normalized = parent::normalize($entity, $format, $context); // Load the resource type for this entity type and bundle. $resource_type = $this->resourceTypeRepository->get($context['entityTypeId'], $context['bundleId']); if (!$resource_type || !$resource_type instanceof ConfigurableResourceType) { return $normalized; } $field_name = $context['name']; $enhancer = $resource_type->getFieldEnhancer($field_name); if (!$enhancer) { return $normalized; } $original_field_schema = $normalized['properties']['attributes']['properties'][$field_name]; $field_schema = &$normalized['properties']['attributes']['properties'][$field_name]; $field_schema = $enhancer->getJsonSchema(); // Copy *some* properties from the original. $copied_properties = ['title', 'description']; foreach ($copied_properties as $property_name) { if (!empty($original_field_schema[$property_name])) { $field_schema[$property_name] = $original_field_schema[$property_name]; } } return $normalized; } }