public function saveCustomer(CustomerDataTransfer $customer)
 {
     $customerdb = $this->customerrepo->findOneBy(array('phone' => $customer->getPhone(), 'lastname' => $customer->getLastname()));
     if ($customerdb === null) {
         $customerdb = new CustomerDB();
         $customerdb->setPhone($customer->getPhone());
         $customerdb->setLastname($customer->getLastname());
         return $customerdb;
     }
     return $customerdb;
 }
 private function createCustomer()
 {
     $customeruser = new Customer();
     $customeruser->setLastname('Moololl');
     $customeruser->setPhone('3333332222');
     $pizza = new \Pizza\CustomerBundle\DataTransferObjects\Pizza();
     $pizza->setAmount(2);
     $pizzaid = $this->pizzatypes[1]->getId();
     $pizza->setType($pizzaid);
     $pizza->addTopping($this->toppings[2]->getId());
     $pizza->addTopping($this->toppings[3]->getId());
     $pizza->addTopping($this->toppings[4]->getId());
     $customeruser->addPizza($pizza);
     return $customeruser;
 }
示例#3
0
 public function saveOrder(CustomerDB $customerdb, CustomerContract $customer)
 {
     $customerOrder = new CustomerOrder();
     $customerOrder->setReady(false);
     $customerOrder->setReceived(false);
     $customerOrder->setCustomer($customerdb);
     foreach ($customer->getPizzas() as $pizza) {
         $item = new CustomerOrderItem();
         $item->setAmount($pizza->getAmount());
         $item->setProduct($this->products[$pizza->getType()]);
         foreach ($pizza->getToppings() as $topping) {
             $subitem = new CustomerOrderSubItem();
             $subitem->setProduct($this->products[$topping]);
             $subitem->setItem($item);
             $item->addSubitem($subitem);
         }
         $item->setCustomerorder($customerOrder);
         $customerOrder->addOrderitems($item);
     }
     $customerdb->addCustomerorder($customerOrder);
     return $customerdb;
 }