lib/boab/ecommerce-bundle/src/Form/CartType.php line 14

Open in your IDE?
  1. <?php
  2. namespace Boab\EcommerceBundle\Form;
  3. use Boab\EcommerceBundle\Form\EventListener\ClearCartListener;
  4. use Boab\EcommerceBundle\Form\EventListener\RemoveCartItemListener;
  5. use Boab\EcommerceBundle\Entity\Cart;
  6. use Symfony\Component\Form\AbstractType;
  7. use Symfony\Component\Form\Extension\Core\Type\CollectionType;
  8. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  9. use Symfony\Component\Form\FormBuilderInterface;
  10. use Symfony\Component\OptionsResolver\OptionsResolver;
  11. class CartType extends AbstractType
  12. {
  13.     public function buildForm(FormBuilderInterface $builder, array $options)
  14.     {
  15.         $builder
  16.             ->add('items'CollectionType::class, [
  17.                 'entry_type' => CartItemType::class,
  18.             ])
  19.             ->add('save'SubmitType::class,[
  20.                 'label'=>'Proceed to checkout'
  21.             ])
  22.             ->add('clear'SubmitType::class,[
  23.                 'label' => 'Clear cart'
  24.             ]);
  25.         $builder->addEventSubscriber(new RemoveCartItemListener());
  26.         $builder->addEventSubscriber(new ClearCartListener());
  27.     }
  28.     public function configureOptions(OptionsResolver $resolver)
  29.     {
  30.         $resolver->setDefaults([
  31.             'data_class' => Cart::class,
  32.         ]);
  33.     }
  34. }