// RendererInterface::render() outside of a render context, then the
// bubbleable metadata for that is stored in the current render context.
if (!
$context->
isEmpty()) { /** @var \Drupal\Core\Render\BubbleableMetadata $early_rendering_bubbleable_metadata */
$early_rendering_bubbleable_metadata =
$context->
pop();
// If a render array or AjaxResponse is returned by the controller, merge
// the "lost" bubbleable metadata.
if (is_array($response)) { BubbleableMetadata::
createFromRenderArray($response) ->
merge($early_rendering_bubbleable_metadata) ->
applyTo($response);
} elseif ($response instanceof AjaxResponse
) { $response->
addAttachments($early_rendering_bubbleable_metadata->
getAttachments());
// @todo Make AjaxResponse cacheable in
// https://www.drupal.org/node/956186. Meanwhile, allow contrib
// subclasses to be.
if ($response instanceof CacheableResponseInterface
) { $response->
addCacheableDependency($early_rendering_bubbleable_metadata);
} } // If a non-Ajax Response or domain object is returned and it cares about