/** * @param Basket $basket * @return BasketItemUpdateAction */ public function setBasketItem(Basket $basket) { if (!$basket->isOwnedBy($this->user)) { throw new NotFoundHttpException("Basket item does not exists"); } parent::setObject($basket); return $this; }
/** * @return Basket|\Symfony\Component\Form\FormInterface */ private function handleForm() { $item = new Basket(); $item->setOwner($this->user); $form = $this->formFactory->createNamed('', $this->type, $item); $form->handleRequest($this->stack->getCurrentRequest()); if ($form->isValid()) { $this->repository->add($item); $this->postCreate($item); return $item; } return $form; }
/** * @Given /^basket item with "([^"]*)" products exists$/ */ public function basketItemWithProductsExists($quantity) { $product = $this->getParameterBag()->get('product'); $user = $this->getParameterBag()->get('user'); $basketItem = new Basket(); $basketItem->setProduct($product); $basketItem->setQuantity($quantity); $basketItem->setOwner($user); $this->getEntityManager()->persist($basketItem); $this->getEntityManager()->flush(); $this->getParameterBag()->set('basket', $basketItem); }
public static function createFromBasket(Basket $item, Order $order) { return new OrderItem($item->getProduct(), $item->getQuantity(), $item->getOwner(), $order); }