/** * "Success" form handler * * @param Cart $entity */ protected function onSuccess(Cart $entity) { $count = 0; /** @var CartItem $item */ foreach ($entity->getCartItems() as $item) { $item->setCart($entity); ++$count; } $entity->setItemsCount($count); if (null === $entity->getOrganization()) { $entity->setOrganization($this->organization); } if ($entity->getShippingAddress() instanceof AbstractAddress && null === $entity->getShippingAddress()->getOrganization()) { $entity->getShippingAddress()->setOrganization($this->organization); } if ($entity->getBillingAddress() instanceof AbstractAddress && null === $entity->getBillingAddress()->getOrganization()) { $entity->getBillingAddress()->setOrganization($this->organization); } $this->manager->persist($entity); $this->manager->flush(); }
/** * "Success" form handler * * @param Order $entity */ protected function onSuccess(Order $entity) { if (null === $entity->getOrganization()) { $entity->setOrganization($this->organization); } /** @var OrderAddress $address */ foreach ($entity->getAddresses() as $address) { if (null === $address->getOwner()) { $address->setOwner($entity); } if (null === $address->getOrganization()) { $address->setOrganization($this->organization); } } /** @var OrderItem $item */ foreach ($entity->getItems() as $item) { if (null === $item->getOrder()) { $item->setOrder($entity); } } $this->manager->persist($entity); $this->manager->flush(); }
/** * "Success" form handler * * @param CartItem $entity */ protected function onSuccess(CartItem $entity) { $this->manager->persist($entity); $this->manager->flush(); }