vendor/sylius/sylius/src/Sylius/Bundle/OrderBundle/Form/Type/CartItemType.php line 21

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Sylius package.
  4.  *
  5.  * (c) Paweł Jędrzejewski
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. declare(strict_types=1);
  11. namespace Sylius\Bundle\OrderBundle\Form\Type;
  12. use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
  13. use Symfony\Component\Form\DataMapperInterface;
  14. use Symfony\Component\Form\Extension\Core\Type\IntegerType;
  15. use Symfony\Component\Form\FormBuilderInterface;
  16. class CartItemType extends AbstractResourceType
  17. {
  18.     private DataMapperInterface $dataMapper;
  19.     public function __construct(
  20.         string $dataClass,
  21.         array $validationGroups,
  22.         DataMapperInterface $dataMapper
  23.     ) {
  24.         parent::__construct($dataClass$validationGroups);
  25.         $this->dataMapper $dataMapper;
  26.     }
  27.     public function buildForm(FormBuilderInterface $builder, array $options): void
  28.     {
  29.         $builder
  30.             ->add('quantity'IntegerType::class, [
  31.                 'attr' => ['min' => 1],
  32.                 'label' => 'sylius.ui.quantity',
  33.             ])
  34.             ->setDataMapper($this->dataMapper)
  35.         ;
  36.     }
  37.     public function getBlockPrefix(): string
  38.     {
  39.         return 'sylius_cart_item';
  40.     }
  41. }