lib/composer/OrderBundle/src/VisualMedia/OrderBundle/Form/Type/CartItemType.php line 22

Open in your IDE?
  1. <?php
  2. /**
  3. * CartItemModel Type
  4. *
  5. * @author Bertin van den Ham <b.vandenham@visualmedia.nl>
  6. */
  7. namespace VisualMedia\OrderBundle\Form\Type;
  8. use Symfony\Component\Form\AbstractType;
  9. use Symfony\Component\Form\Extension\Core\Type\IntegerType;
  10. use Symfony\Component\Form\FormBuilderInterface;
  11. use Symfony\Component\OptionsResolver\OptionsResolver;
  12. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  13. use Symfony\Component\Routing\RouterInterface;
  14. use VisualMedia\OrderBundle\Entity\BaseOrderItem;
  15. /**
  16. * CartItemModel Type
  17. */
  18. class CartItemType extends AbstractType
  19. {
  20. public const NAME = 'cart_item';
  21. /**
  22. * @var RouterInterface
  23. */
  24. protected $router;
  25. /**
  26. * CartItemType.
  27. */
  28. public function __construct(RouterInterface $router)
  29. {
  30. $this->router = $router;
  31. }
  32. /**
  33. * {@inheritdoc}
  34. */
  35. public function buildForm(FormBuilderInterface $builder, array $options)
  36. {
  37. $builder->add('amount', IntegerType::class, array(
  38. 'label' => false,
  39. 'error_bubbling' => true,
  40. 'attr' => array(
  41. 'data-route-cart-item-amount' => $this->router->generate('cart_item_amount'),
  42. 'min' => 1,
  43. ),
  44. ));
  45. }
  46. /**
  47. * {@inheritDoc}
  48. */
  49. public function getName(): string
  50. {
  51. return static::NAME;
  52. }
  53. /**
  54. * {@inheritdoc}
  55. */
  56. public function configureOptions(OptionsResolver $resolver)
  57. {
  58. $resolver->setDefaults(array(
  59. 'translation_domain' => 'forms',
  60. 'data_class' => BaseOrderItem::class
  61. ));
  62. }
  63. }