/** * {@inheritdoc} */ public function createNew() { if (null === ($productId = $this->getRequest()->get('productId'))) { throw new NotFoundHttpException('No parent product given.'); } $product = $this->findProductOr404($productId); $variant = parent::createNew(); $variant->setProduct($product); return $variant; }
/** * {@inheritdoc} */ public function createNew() { $request = $this->config->getRequest(); if (null === ($countryId = $request->get('countryId'))) { throw new NotFoundHttpException('No country given'); } $country = $this->getCountryController()->findOr404($request, ['id' => $countryId]); $province = parent::createNew(); $province->setCountry($country); return $province; }
/** * {@inheritdoc} */ public function createNew() { $request = $this->getRequest(); if (null === ($promotionId = $request->get('promotionId'))) { throw new NotFoundHttpException('No promotion id given'); } $promotion = $this->getPromotionController()->findOr404($request, array('id' => $promotionId)); $coupon = parent::createNew(); $coupon->setPromotion($promotion); return $coupon; }
/** * {@inheritdoc} */ public function createNew() { if (null === ($orderId = $this->getRequest()->get('orderId'))) { return new JsonResponse(array('error' => 'Missing order id.'), 400); } if (!($order = $this->getOrderRepository()->find($orderId))) { $this->createNotFoundException('Requested order does not exist.'); } $adjustment = parent::createNew(); $adjustment->setAdjustable($order); return $adjustment; }
/** * {@inheritdoc} */ public function createNew() { if (null === ($orderId = $this->getRequest()->get('orderId'))) { throw new NotFoundHttpException('No order id given.'); } if (!($order = $this->getOrderRepository()->find($orderId))) { throw new NotFoundHttpException('Requested order does not exist.'); } $orderItem = parent::createNew(); $orderItem->setOrder($order); return $orderItem; }
/** * {@inheritdoc} */ public function createNew() { if (null === ($taxonomyId = $this->getRequest()->get('taxonomyId'))) { throw new NotFoundHttpException('No taxonomy id given.'); } if (!($taxonomy = $this->getTaxonomyRepository()->find($taxonomyId))) { throw new NotFoundHttpException('Requested taxonomy does not exist.'); } $taxon = parent::createNew(); $taxon->setTaxonomy($taxonomy); return $taxon; }
/** * {@inheritdoc} */ public function createNew() { $product = parent::createNew(); $code = $this->getRequest()->query->get('archetype'); if (null === $code) { return $product; } $archetype = $this->getArchetypeRepository()->findOneBy(array('code' => $code)); if (!$archetype) { throw new NotFoundHttpException(sprintf('Requested archetype does not exist!')); } $product->setArchetype($archetype); $this->getBuilder()->build($product); return $product; }