Sonata\BasketBundle\Controller\BasketController::deliveryStepAction PHP Method

deliveryStepAction() public method

Order process step 3: choose delivery mode.
public deliveryStepAction ( ) : RedirectResponse | Response
return Symfony\Component\HttpFoundation\RedirectResponse | Symfony\Component\HttpFoundation\Response
    public function deliveryStepAction()
    {
        $basket = $this->get('sonata.basket');
        if ($basket->countBasketElements() == 0) {
            return new RedirectResponse($this->generateUrl('sonata_basket_index'));
        }
        $customer = $basket->getCustomer();
        if (!$customer) {
            throw new NotFoundHttpException('customer not found');
        }
        try {
            $form = $this->createForm('sonata_basket_shipping', $basket, array('validation_groups' => array('delivery')));
        } catch (UndeliverableCountryException $ex) {
            $countryName = Intl::getRegionBundle()->getCountryName($ex->getAddress()->getCountryCode());
            $message = $this->get('translator')->trans('undeliverable_country', array('%country%' => $countryName), 'SonataBasketBundle');
            $this->get('session')->getFlashBag()->add('error', $message);
            return new RedirectResponse($this->generateUrl('sonata_basket_index'));
        }
        $template = 'SonataBasketBundle:Basket:delivery_step.html.twig';
        if ($this->get('request')->getMethod() == 'POST') {
            $form->bind($this->get('request'));
            if ($form->isValid()) {
                // save the basket
                $this->get('sonata.basket.factory')->save($form->getData());
                return new RedirectResponse($this->generateUrl('sonata_basket_payment_address'));
            }
        }
        $this->get('sonata.seo.page')->setTitle($this->get('translator')->trans('basket_delivery_title', array(), 'SonataBasketBundle'));
        return $this->render($template, array('basket' => $basket, 'form' => $form->createView(), 'customer' => $customer));
    }