Esempio n. 1
0
 private function createProductLine(Order $order, $productSaleId, $quantity)
 {
     $productLine = new OrderProductLine();
     $productLine->setProductSale($this->doctrine->getRepository(ProductSale::REPOSITORY)->find($productSaleId));
     $productLine->setQuantity($quantity);
     $productLine->setOrder($order);
     $order->addProductLine($productLine);
     $this->entityManager->persist($productLine);
 }
Esempio n. 2
0
 /**
  * Edits an existing Order entity.
  *
  */
 public function updateAction(Request $request, $id)
 {
     $entityManager = $this->getDoctrine()->getManager();
     $postOrder = $request->get('appbundle_order');
     $quantities = $request->get('quantity');
     $order = $entityManager->getRepository(Order::REPOSITORY)->find($id);
     if (!$order) {
         throw $this->createNotFoundException('Unable to find Order entity.');
     }
     $order->setCustomer($entityManager->getRepository(Customer::REPOSITORY)->find($postOrder['customer']));
     foreach ($order->getProductLines() as $productLine) {
         $entityManager->remove($productLine);
     }
     foreach ($postOrder['productLines'] as $productSaleId => $value) {
         $productLine = new OrderProductLine();
         $productLine->setProductSale($entityManager->getRepository(ProductSale::REPOSITORY)->find($productSaleId));
         $productLine->setQuantity($quantities[$productSaleId]);
         $entityManager->persist($productLine);
         $order->addProductLine($productLine);
     }
     $entityManager->persist($order);
     $entityManager->flush();
     return $this->redirect($this->generateUrl('order_show', array('id' => $order->getId())));
 }
Esempio n. 3
0
 public function addProductLine(OrderProductLine $productLine)
 {
     $productLine->setOrder($this);
     $this->productLines[] = $productLine;
     return $this;
 }