class DummyRedirectController in Commerce Core 8.2
This is a dummy controller for mocking an off-site gateway.
Hierarchy
- class \Drupal\commerce_payment_example\Controller\DummyRedirectController implements ContainerInjectionInterface
Expanded class hierarchy of DummyRedirectController
File
- modules/
payment_example/ src/ Controller/ DummyRedirectController.php, line 13
Namespace
Drupal\commerce_payment_example\ControllerView source
class DummyRedirectController implements ContainerInjectionInterface {
/**
* The current request.
*
* @var \Symfony\Component\HttpFoundation\Request
*/
protected $currentRequest;
/**
* Constructs a new DummyRedirectController object.
*
* @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
* The request stack.
*/
public function __construct(RequestStack $request_stack) {
$this->currentRequest = $request_stack
->getCurrentRequest();
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('request_stack'));
}
/**
* Callback method which accepts POST.
*
* @throws \Drupal\commerce\Response\NeedsRedirectException
*/
public function post() {
$cancel = $this->currentRequest->request
->get('cancel');
$return = $this->currentRequest->request
->get('return');
$total = $this->currentRequest->request
->get('total');
if ($total > 20) {
return new TrustedRedirectResponse($return);
}
return new TrustedRedirectResponse($cancel);
}
/**
* Callback method which reacts to GET from a 302 redirect.
*
* @throws \Drupal\commerce\Response\NeedsRedirectException
*/
public function on302() {
$cancel = $this->currentRequest->query
->get('cancel');
$return = $this->currentRequest->query
->get('return');
$total = $this->currentRequest->query
->get('total');
if ($total > 20) {
return new TrustedRedirectResponse($return);
}
return new TrustedRedirectResponse($cancel);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DummyRedirectController:: |
protected | property | The current request. | |
DummyRedirectController:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
DummyRedirectController:: |
public | function | Callback method which reacts to GET from a 302 redirect. | |
DummyRedirectController:: |
public | function | Callback method which accepts POST. | |
DummyRedirectController:: |
public | function | Constructs a new DummyRedirectController object. |