Skip to content

Commit

Permalink
Merge pull request #200 from rossriley/fix/return-early-on-redirect
Browse files Browse the repository at this point in the history
return early if there is a redirect
  • Loading branch information
rossriley authored Oct 18, 2017
2 parents c70043f + e254959 commit 6bac1b9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/Submission/Handler/Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,14 @@ public function __construct(RedirectableUrlMatcher $urlMatcher)
* Do a redirect.
*
* @param FormConfig $formConfig
* @param Entity $formData
* @param Entity $formData
* @return RedirectResponse
*/
public function handle(FormConfig $formConfig, Entity $formData)
{
$response = $this->getRedirectResponse($formConfig, $formData);
if ($response instanceof RedirectResponse) {
$response->send();
return $response->send();
}
}

Expand Down
6 changes: 5 additions & 1 deletion src/Submission/Processor/Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Bolt\Extension\Bolt\BoltForms\Submission\Handler;
use Pimple as Container;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
Expand Down Expand Up @@ -77,7 +78,10 @@ public function process(LifecycleEvent $lifeEvent, $eventName, EventDispatcherIn
/** @var Handler\Redirect $handler */
$handler = $this->handlers['redirect'];
if ($formConfig->getFeedback()->getRedirectTarget() !== null) {
$handler->handle($formConfig, $formData);
$response = $handler->handle($formConfig, $formData);
if ($response instanceof RedirectResponse) {
return;
}
}

// Do a get on the page as it was probably POSTed
Expand Down

0 comments on commit 6bac1b9

Please sign in to comment.