Skip to content

Commit

Permalink
Merge pull request #284 from xiaohutai/4.2
Browse files Browse the repository at this point in the history
Fix flash messages again -- See #283 [EXPERIMENTAL]
  • Loading branch information
bobdenotter committed May 15, 2019
2 parents c435dfc + 8ffaad2 commit 83f6032
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
6 changes: 2 additions & 4 deletions src/Submission/Handler/Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,25 @@ public function __construct(RedirectableUrlMatcher $urlMatcher)
*
* @param FormConfig $formConfig
* @param Entity $formData
* @return RedirectResponse
*/
public function handle(FormConfig $formConfig, Entity $formData)
{
$response = $this->getRedirectResponse($formConfig, $formData);
if ($response instanceof RedirectResponse) {
return $response->send();
$response->send();
}
}

/**
* Refresh the current page.
*
* @param Request $request
* @return RedirectResponse
*/
public function refresh(Request $request)
{
$response = new RedirectResponse($request->getRequestUri());

return $response->send();
$response->send();
}

/**
Expand Down
15 changes: 6 additions & 9 deletions src/Submission/Processor/Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,17 @@ public function process(LifecycleEvent $lifeEvent, $eventName, EventDispatcherIn
/** @var Handler\Redirect $handler */
$handler = $this->handlers['redirect'];
if ($formConfig->getFeedback()->getRedirectTarget() !== null) {
$response = $handler->handle($formConfig, $formData);
if ($response instanceof RedirectResponse) {
return;
}
$handler->handle($formConfig, $formData);
}

// Do a get on the page as it was probably POSTed
$request = $this->requestStack->getCurrentRequest();

$response = $handler->refresh($request);
if ($response instanceof RedirectResponse) {
return;
}
$handler->refresh($request);

throw new HttpException(Response::HTTP_FOUND, '', null, []);
// Just 'exit'-ing is bad practice, but in this case it prevents an oscure error.
// @see https://github.com/bolt/boltforms/pull/284 for details
exit;
// throw new HttpException(Response::HTTP_FOUND, '', null, []);
}
}

0 comments on commit 83f6032

Please sign in to comment.