You are here

public function CheckoutController::formPage in Commerce Core 8.2

Builds and processes the form provided by the order's checkout flow.

Parameters

\Drupal\Core\Routing\RouteMatchInterface $route_match: The route match.

Return value

array|\Symfony\Component\HttpFoundation\RedirectResponse The render form.

1 string reference to 'CheckoutController::formPage'
commerce_checkout.routing.yml in modules/checkout/commerce_checkout.routing.yml
modules/checkout/commerce_checkout.routing.yml

File

modules/checkout/src/Controller/CheckoutController.php, line 131

Class

CheckoutController
Provides the checkout form page.

Namespace

Drupal\commerce_checkout\Controller

Code

public function formPage(RouteMatchInterface $route_match) {

  /** @var \Drupal\commerce_order\Entity\OrderInterface $order */
  $order = $route_match
    ->getParameter('commerce_order');
  $requested_step_id = $route_match
    ->getParameter('step');
  $step_id = $this->checkoutOrderManager
    ->getCheckoutStepId($order, $requested_step_id);
  if ($requested_step_id != $step_id) {
    $url = Url::fromRoute('commerce_checkout.form', [
      'commerce_order' => $order
        ->id(),
      'step' => $step_id,
    ]);
    return new RedirectResponse($url
      ->toString());
  }
  $checkout_flow = $this->checkoutOrderManager
    ->getCheckoutFlow($order);
  $checkout_flow_plugin = $checkout_flow
    ->getPlugin();
  return $this->formBuilder
    ->getForm($checkout_flow_plugin, $step_id);
}