vendor/sylius/sylius/src/Sylius/Bundle/CoreBundle/Form/Type/Order/AddToCartType.php line 22

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\CoreBundle\Form\Type\Order;
  12. use Sylius\Bundle\OrderBundle\Form\Type\CartItemType;
  13. use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
  14. use Sylius\Component\Core\Model\ProductInterface;
  15. use Symfony\Component\Form\FormBuilderInterface;
  16. use Symfony\Component\OptionsResolver\OptionsResolver;
  17. final class AddToCartType extends AbstractResourceType
  18. {
  19.     public function buildForm(FormBuilderInterface $builder, array $options): void
  20.     {
  21.         $builder->add('cartItem'CartItemType::class, ['product' => $options['product']]);
  22.     }
  23.     public function configureOptions(OptionsResolver $resolver): void
  24.     {
  25.         parent::configureOptions($resolver);
  26.         $resolver
  27.             ->setDefined([
  28.                 'product',
  29.             ])
  30.             ->setAllowedTypes('product'ProductInterface::class)
  31.         ;
  32.     }
  33.     public function getBlockPrefix(): string
  34.     {
  35.         return 'sylius_add_to_cart';
  36.     }
  37. }