You are here

class CheckoutCompletionRegisterEvent in Commerce Core 8.2

Defines the checkout completion register event.

Hierarchy

Expanded class hierarchy of CheckoutCompletionRegisterEvent

See also

\Drupal\commerce_checkout\Event\CheckoutEvents

2 files declare their use of CheckoutCompletionRegisterEvent
CheckoutSubscriber.php in modules/checkout/tests/modules/commerce_checkout_test/src/EventSubscriber/CheckoutSubscriber.php
CompletionRegister.php in modules/checkout/src/Plugin/Commerce/CheckoutPane/CompletionRegister.php

File

modules/checkout/src/Event/CheckoutCompletionRegisterEvent.php, line 15

Namespace

Drupal\commerce_checkout\Event
View source
class CheckoutCompletionRegisterEvent extends EventBase {

  /**
   * The created account.
   *
   * @var \Drupal\Core\Session\AccountInterface
   */
  protected $account;

  /**
   * The checkout order.
   *
   * @var \Drupal\commerce_order\Entity\OrderInterface
   */
  protected $order;

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

  /**
   * Constructs a new CheckoutCompletionRegisterEvent object.
   *
   * @param \Drupal\Core\Session\AccountInterface $account
   *   The created account.
   * @param \Drupal\commerce_order\Entity\OrderInterface $order
   *   The checkout order.
   */
  public function __construct(AccountInterface $account, OrderInterface $order) {
    $this->account = $account;
    $this->order = $order;
  }

  /**
   * Gets the created account.
   *
   * @return \Drupal\Core\Session\AccountInterface
   *   The created account.
   */
  public function getAccount() {
    return $this->account;
  }

  /**
   * Gets the checkout order.
   *
   * @return \Drupal\commerce_order\Entity\OrderInterface
   *   The checkout order.
   */
  public function getOrder() {
    return $this->order;
  }

  /**
   * Gets the redirect URL.
   *
   * Used to redirect the customer after the account has been created.
   *
   * @return \Drupal\Core\Url|null
   *   The redirect url, if set. NULL otherwise.
   */
  public function getRedirectUrl() {
    return $this->redirect;
  }

  /**
   * Sets the redirect URL.
   *
   * @param \Drupal\Core\Url $url
   *   The redirect URL.
   *
   * @return $this
   */
  public function setRedirectUrl(Url $url) {
    $this->redirect = $url;
    return $this;
  }

  /**
   * Sets the redirect.
   *
   * @param string $route_name
   *   The name of the route.
   * @param array $route_parameters
   *   (optional) An associative array of parameter names and values.
   * @param array $options
   *   (optional) An associative array of additional options. See
   *   \Drupal\Core\Url for the available keys.
   *
   * @return $this
   */
  public function setRedirect($route_name, array $route_parameters = [], array $options = []) {
    $url = new Url($route_name, $route_parameters, $options);
    return $this
      ->setRedirectUrl($url);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CheckoutCompletionRegisterEvent::$account protected property The created account.
CheckoutCompletionRegisterEvent::$order protected property The checkout order.
CheckoutCompletionRegisterEvent::$redirect protected property The redirect URL.
CheckoutCompletionRegisterEvent::getAccount public function Gets the created account.
CheckoutCompletionRegisterEvent::getOrder public function Gets the checkout order.
CheckoutCompletionRegisterEvent::getRedirectUrl public function Gets the redirect URL.
CheckoutCompletionRegisterEvent::setRedirect public function Sets the redirect.
CheckoutCompletionRegisterEvent::setRedirectUrl public function Sets the redirect URL.
CheckoutCompletionRegisterEvent::__construct public function Constructs a new CheckoutCompletionRegisterEvent object.