diff --git a/core/modules/text/src/Normalizer/TextItemBaseNormalizer.php b/core/modules/text/src/Normalizer/TextItemBaseNormalizer.php index d8329f3..72a76f7 100644 --- a/core/modules/text/src/Normalizer/TextItemBaseNormalizer.php +++ b/core/modules/text/src/Normalizer/TextItemBaseNormalizer.php @@ -4,6 +4,7 @@ use Drupal\Core\Cache\ConditionalCacheabilityMetadataBubblingTrait; use Drupal\Core\Config\ConfigFactoryInterface; +use Drupal\Core\Render\RenderContext; use Drupal\Core\Render\RendererInterface; use Drupal\filter\FilterProcessResult; use Drupal\serialization\Normalizer\ComplexDataNormalizer; @@ -84,26 +85,16 @@ public function normalize($field_item, $format = NULL, array $context = []) { * @see \Drupal\text\Plugin\Field\FieldType\TextItemBase::propertyDefinitions() */ protected function computeProcessedAttribute(TextItemBase $field_item) { - $value = $field_item->getValue(); - if (empty($value['format'])) { - $filter_settings = $this->configFactory->get('filter.settings'); - $this->bubble($filter_settings); - $filter_format_id = $filter_settings->get('fallback_format'); - } - else { - $filter_format_id = $value['format']; - } - $build = [ - '#type' => 'processed_text', - '#text' => $value['value'], - '#format' => $filter_format_id, - '#filter_types_to_skip' => [], - '#langcode' => '', - ]; + + $render_context = new RenderContext(); // It's necessary to capture the cacheability metadata associated with the // processed text. See https://www.drupal.org/node/2278483. - $processed_text = $this->renderer->renderPlain($build); - return FilterProcessResult::createFromRenderArray($build)->setProcessedText($processed_text); + $processed_text = $this->renderer->executeInRenderContext($render_context, function () use ($field_item) { + return $field_item->processed; + }); + + return (new FilterProcessResult($processed_text)) + ->merge($render_context->bubble()); } }