if (!
empty($attached['html_response_attachment_placeholders'
])) { // Get the placeholders from attached and then remove them.
$attachment_placeholders =
$attached['html_response_attachment_placeholders'
];
unset($attached['html_response_attachment_placeholders'
]);
$assets = AttachedAssets::
createFromRenderArray(['#attached' =>
$attached]);
// Take Ajax page state into account, to allow for something like
// Turbolinks to be implemented without altering core.
// @see https://github.com/rails/turbolinks/
$ajax_page_state =
$this->requestStack->
getCurrentRequest()->
get('ajax_page_state'
);
$assets->
setAlreadyLoadedLibraries(isset($ajax_page_state) ?
explode(',',
$ajax_page_state['libraries'
]) :
[]);
$variables =
$this->
processAssetLibraries($assets,
$attachment_placeholders);
// $variables now contains the markup to load the asset libraries. Update
// $attached with the final list of libraries and JavaScript settings, so
// that $response can be updated with those. Then the response object will
// list the final, processed attachments.
$attached['library'
] =
$assets->
getLibraries();
$attached['drupalSettings'
] =
$assets->
getSettings();
// Since we can only replace content in the HTML head section if there's a
// placeholder for it, we can safely avoid processing the render array if
// it's not present.
if (!
empty($attachment_placeholders['head'
])) {