.../Core/Render/HtmlResponseAttachmentsProcessor.php | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php b/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php
index cc20063..19edef1 100644
--- a/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php
+++ b/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php
@@ -10,6 +10,7 @@
use Drupal\Core\Asset\AssetResolverInterface;
use Drupal\Core\Asset\AttachedAssets;
use Drupal\Core\Config\ConfigFactoryInterface;
+use Drupal\Core\Form\EnforcedResponseException;
use Symfony\Component\HttpFoundation\RequestStack;
/**
@@ -103,7 +104,18 @@ public function processAttachments(AttachmentsInterface $response) {
// attachments to be added to the response, which the attachment
// placeholders rendered by renderHtmlResponseAttachmentPlaceholders() will
// need to include.
- $response = $this->renderPlaceholders($response);
+ //
+ // @todo Exceptions should not be used for code flow control. However, the
+ // Form API does not integrate with the HTTP Kernel based architecture of
+ // 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();
+ }
$attached = $response->getAttachments();