src/Form/Type/Admin/OrderItemType.php line 27

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 App\Form\Type\Admin;
  12. use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
  13. use Sylius\Bundle\ResourceBundle\Form\Type\ResourceAutocompleteChoiceType;
  14. use Symfony\Component\Form\DataMapperInterface;
  15. use Symfony\Component\Form\Extension\Core\Type\IntegerType;
  16. use Symfony\Component\Form\FormBuilderInterface;
  17. final class OrderItemType extends AbstractResourceType
  18. {
  19.     /** @var DataMapperInterface */
  20.     private $dataMapper;
  21.     public function __construct(
  22.         string $dataClass,
  23.         array $validationGroups = [],
  24.         DataMapperInterface $dataMapper
  25.     ) {
  26.         parent::__construct($dataClass$validationGroups);
  27.         $this->dataMapper $dataMapper;
  28.     }
  29.     public function buildForm(FormBuilderInterface $builder, array $options): void
  30.     {
  31.         $builder
  32.             ->add('variant'ResourceAutocompleteChoiceType::class, [
  33.                 'label' => 'sylius.ui.variant',
  34.                 'choice_name' => 'descriptor',
  35.                 'choice_value' => 'code',
  36.                 'resource' => 'sylius.product_variant',
  37.             ])
  38.             ->add('quantity'IntegerType::class, [
  39.                 'attr' => ['min' => 1],
  40.                 'label' => 'sylius.ui.quantity',
  41.             ])
  42.             ->setDataMapper($this->dataMapper)
  43.         ;
  44.     }
  45.     public function getBlockPrefix(): string
  46.     {
  47.         return 'app_order_update_item_block';
  48.     }
  49. }