public function indexAction($form = null)
    {
        $form = $form ?: $this->createForm(BasketType::class, $this->get('sonata.basket'), [
            'validation_groups' => ['elements'],
        ]);

        // always validate the basket
        if (!$form->isSubmitted()) {
            if ($violations = $this->get('validator')->validate($form)) {
                $violationMapper = new ViolationMapper();
                foreach ($violations as $violation) {
                    $violationMapper->mapViolation($violation, $form, true);
                }
            }
        }

        $this->get('session')->set('sonata_basket_delivery_redirect', 'sonata_basket_delivery_address');

        $this->get('sonata.seo.page')->setTitle($this->get('translator')->trans('basket_index_title', [], 'SonataBasketBundle'));

        return $this->render('SonataBasketBundle:Basket:index.html.twig', [
            'basket' => $this->get('sonata.basket'),
            'form' => $form->createView(),
        ]);
    }
public function indexAction($form = null)
    {
        $form = $form ?: $this->createForm(BasketType::class, $this->get('sonata.basket'), [
            'validation_groups' => ['elements'],
        ]);

        // always validate the basket
        if (!$form->isSubmitted()) {
            if ($violations = $this->get('validator')->validate($form)) {
                $violationMapper = new ViolationMapper();
                foreach ($violations as $violation) {
                    $violationMapper->mapViolation($violation, $form, true);
                }
            }
        }

        $this->get('session')->set('sonata_basket_delivery_redirect', 'sonata_basket_delivery_address');

        $this->get('sonata.seo.page')->setTitle($this->get('translator')->trans('basket_index_title', [], 'SonataBasketBundle'));

        return $this->render('SonataBasketBundle:Basket:index.html.twig', [
            'basket' => $this->get('sonata.basket'),
            'form' => $form->createView(),
        ]);
    }
public function indexAction ( $ form = null ) { $ form = $ form ? : $ this -> createForm ( BasketType :: class , $ this -> get ( 'sonata.basket' ) , [ 'validation_groups' => [ 'elements' ] , ] ) ; // always validate the basket if ( ! $ form -> isSubmitted ( ) ) { if ( $ violations = $ this -> get ( 'validator' ) -> validate ( $ form ) ) { $ violationMapper = new ViolationMapper ( ) ; foreach ( $ violations as $ violation ) { $ violationMapper -> mapViolation ( $ violation , $ form , true ) ; } } } $ this -> get ( 'session' ) -> set ( 'sonata_basket_delivery_redirect' , 'sonata_basket_delivery_address' ) ; $ this -> get ( 'sonata.seo.page' ) -> setTitle ( $ this -> get ( 'translator' ) -> trans ( 'basket_index_title' , [ ] , 'SonataBasketBundle' ) ) ; return $ this -> render ( 'SonataBasketBundle:Basket:index.html.twig' , [ 'basket' => $ this -> get ( 'sonata.basket' ) , 'form' => $ form -> createView ( ) , ] ) ; }
Shows the basket.

@param Form $form

@return Response
Shows the basket .