You are here

class Response in Payment 8.2

Provides a payment response.

Hierarchy

Expanded class hierarchy of Response

4 files declare their use of Response
PaymentForm.php in modules/payment_form/src/Plugin/Payment/Type/PaymentForm.php
PaymentReference.php in modules/payment_reference/src/Plugin/Payment/Type/PaymentReference.php
PaymentTestResponse.php in modules/payment_test/src/Plugin/Payment/Method/PaymentTestResponse.php
ResponseTest.php in tests/src/Unit/Response/ResponseTest.php

File

src/Response/Response.php, line 12

Namespace

Drupal\payment\Response
View source
class Response implements ResponseInterface {

  /**
   * The redirect URL.
   *
   * @var \Drupal\Core\Url
   */
  protected $url;

  /**
   * The response.
   *
   * @var \Symfony\Component\HttpFoundation\Response|null
   */
  protected $response;

  /**
   * Creates a new instance.
   *
   * @param \Drupal\Core\Url $url
   * @param \Symfony\Component\HttpFoundation\Response|null $response
   */
  public function __construct(Url $url, SymfonyResponse $response = NULL) {
    $this->response = $response;
    $this->url = $url;
  }

  /**
   * {@inheritdoc}
   */
  public function getRedirectUrl() {
    return $this->url;
  }

  /**
   * {@inheritdoc}
   */
  public function getResponse() {
    if (!$this->response) {

      // Ensure that bubbleable metadata is collected and added to the response
      // object.
      $url = $this->url
        ->toString(TRUE);
      $this->response = new TrustedRedirectResponse($url
        ->getGeneratedUrl());
      $this->response
        ->addCacheableDependency($url);
    }
    return $this->response;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Response::$response protected property The response.
Response::$url protected property The redirect URL.
Response::getRedirectUrl public function Gets the URL the calling code may redirect to after payment execution. Overrides ResponseInterface::getRedirectUrl
Response::getResponse public function Gets the response the calling code must return after payment execution. Overrides ResponseInterface::getResponse
Response::__construct public function Creates a new instance.