Skip to content

Commit 1daf205

Browse files
committed
Merge pull request #79 from winzou/patch-1
Add a getRedirectResponse method
2 parents 407019a + c5a10ef commit 1daf205

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/Omnipay/Common/Message/AbstractResponse.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,19 @@ public function getTransactionReference()
6767
* redirection page, just call the getRedirectUrl() and getRedirectData() methods directly.
6868
*/
6969
public function redirect()
70+
{
71+
$this->getRedirectResponse()->send();
72+
exit;
73+
}
74+
75+
public function getRedirectResponse()
7076
{
7177
if (!$this instanceof RedirectResponseInterface || !$this->isRedirect()) {
7278
throw new RuntimeException('This response does not support redirection.');
7379
}
7480

7581
if ('GET' === $this->getRedirectMethod()) {
76-
HttpRedirectResponse::create($this->getRedirectUrl())->send();
77-
exit;
82+
return HttpRedirectResponse::create($this->getRedirectUrl());
7883
} elseif ('POST' === $this->getRedirectMethod()) {
7984
$hiddenFields = '';
8085
foreach ($this->getRedirectData() as $key => $value) {
@@ -102,8 +107,7 @@ public function redirect()
102107
</html>';
103108
$output = sprintf($output, htmlspecialchars($this->getRedirectUrl(), ENT_QUOTES, 'UTF-8'), $hiddenFields);
104109

105-
HttpResponse::create($output)->send();
106-
exit;
110+
return HttpResponse::create($output);
107111
}
108112

109113
throw new RuntimeException('Invalid redirect method "'.$this->getRedirectMethod().'".');

0 commit comments

Comments
 (0)