$build =
[ '#type' => 'processed_text',
'#text' =>
$text,
'#format' =>
$filter_format->
id(),
];
$html =
$this->renderer->
renderPlain($build);
// Load the media item so we can embed the label in the response, for use
// in an ARIA label.
$headers =
[];
if ($media =
$this->entityRepository->
loadEntityByUuid('media',
$uuid)) { $headers['Drupal-Media-Label'
] =
$this->entityRepository->
getTranslationFromContext($media)->
label();
} // Note that we intentionally do not use:
// - \Drupal\Core\Cache\CacheableResponse because caching it on the server
// side is wasteful, hence there is no need for cacheability metadata.
// - \Drupal\Core\Render\HtmlResponse because there is no need for
// attachments nor cacheability metadata.
return (new Response($html, 200,
$headers)) // Do not allow any intermediary to cache the response, only the end user.
->
setPrivate()