コード例 #1
0
 /**
  * @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;
 }
コード例 #2
0
 /**
  * @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);
 }