/**
  * {@inheritdoc}
  */
 public function mapFormsToData($forms, &$data)
 {
     $formsOtherThanQuantity = [];
     foreach ($forms as $key => $form) {
         if ('quantity' === $form->getName()) {
             $targetQuantity = $form->getData();
             $this->orderItemQuantityModifier->modify($data, $targetQuantity);
             continue;
         }
         $formsOtherThanQuantity[] = $form;
     }
     if (!empty($formsOtherThanQuantity)) {
         $this->propertyPathDataMapper->mapFormsToData($formsOtherThanQuantity, $data);
     }
 }
Example #2
0
 /**
  * Adds a child to the form.
  *
  * @param FormInterface $child The FormInterface to add as a child
  *
  * @return Form the current form
  */
 public function add(FormInterface $child)
 {
     $this->children[$child->getName()] = $child;
     $child->setParent($this);
     if ($this->dataMapper) {
         $this->dataMapper->mapDataToForm($this->getClientData(), $child);
     }
     return $this;
 }
Example #3
0
 /**
  * Adds a child to the form.
  *
  * @param FormInterface $child The FormInterface to add as a child
  *
  * @return Form the current form
  */
 public function add(FormInterface $child)
 {
     if ($this->bound) {
         throw new AlreadyBoundException('You cannot add children to a bound form');
     }
     $this->children[$child->getName()] = $child;
     $child->setParent($this);
     if ($this->dataMapper) {
         $this->dataMapper->mapDataToForm($this->getClientData(), $child);
     }
     return $this;
 }
 function it_uses_a_property_path_data_mapper_while_mapping_data_to_forms(DataMapperInterface $propertyPathDataMapper, FormInterface $form, OrderItemInterface $orderItem)
 {
     $propertyPathDataMapper->mapDataToForms($orderItem, [$form])->shouldBeCalled();
     $this->mapDataToForms($orderItem, [$form]);
 }