// Drupal 8. In order to resolve this issue properly it is necessary to
// completely separate form submission from rendering.
// @see https://www.drupal.org/node/2367555
try { $response =
$this->
renderPlaceholders($response);
} catch (EnforcedResponseException
$e) { return $e->
getResponse();
} // Get a reference to the attachments.
$attached =
$response->
getAttachments();
// Send a message back if the render array has unsupported #attached types.
$unsupported_types =
array_diff( array_keys($attached),
['html_head', 'feed', 'html_head_link', 'http_header', 'library', 'html_response_attachment_placeholders', 'placeholders', 'drupalSettings'
] );
if (!
empty($unsupported_types)) { throw new \
LogicException(sprintf('You are not allowed to use %s in #attached.',
implode(', ',
$unsupported_types)));
} // If we don't have any placeholders, there is no need to proceed.