-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
services: | ||
|
||
Tests\FluxSE\SyliusPayumMoneticoPlugin\App\Action\GetHttpRequestAction: | ||
decorates: payum.action.get_http_request | ||
arguments: | ||
$decoratedGetHttpRequestAction: '@Tests\FluxSE\SyliusPayumMoneticoPlugin\App\Action\GetHttpRequestAction.inner' | ||
$httpRequestStack: '@request_stack' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\FluxSE\SyliusPayumMoneticoPlugin\App\Action; | ||
|
||
use Payum\Core\Action\ActionInterface; | ||
use Payum\Core\Bridge\Symfony\Action\GetHttpRequestAction as BaseGetHttpRequestAction; | ||
use Payum\Core\Exception\RequestNotSupportedException; | ||
use Symfony\Component\HttpFoundation\RequestStack; | ||
|
||
final class GetHttpRequestAction implements ActionInterface | ||
{ | ||
/** | ||
* @var BaseGetHttpRequestAction | ||
*/ | ||
private $decoratedGetHttpRequestAction; | ||
|
||
/** | ||
* @var RequestStack | ||
*/ | ||
protected $httpRequestStack; | ||
|
||
public function __construct( | ||
BaseGetHttpRequestAction $decoratedGetHttpRequestAction, | ||
RequestStack $httpRequestStack | ||
) { | ||
$this->decoratedGetHttpRequestAction = $decoratedGetHttpRequestAction; | ||
$this->httpRequestStack = $httpRequestStack; | ||
} | ||
|
||
public function execute($request): void | ||
{ | ||
RequestNotSupportedException::assertSupports($this, $request); | ||
|
||
if ($this->httpRequestStack->getCurrentRequest() !== $this->httpRequestStack->getMainRequest()) | ||
{ | ||
$this->decoratedGetHttpRequestAction->setHttpRequest($this->httpRequestStack->getCurrentRequest()); | ||
} | ||
$this->decoratedGetHttpRequestAction->execute($request); | ||
} | ||
|
||
public function supports($request): bool | ||
{ | ||
return $this->decoratedGetHttpRequestAction->supports($request); | ||
} | ||
} |