Beispiel #1
4
 /**
  * @param string $name
  *
  * @return TaxonInterface
  */
 private function createTaxon($name)
 {
     $taxon = $this->taxonFactory->createNew();
     $taxon->setName($name);
     $taxon->setCode($this->getCodeFromName($name));
     return $taxon;
 }
Beispiel #2
0
 /**
  * {@inheritdoc}
  */
 public function createNew()
 {
     /** @var Route $route */
     $route = $this->decoratedFactory->createNew();
     $route->setParentDocument($this->documentManager->find(null, $this->routeParentPath));
     return $route;
 }
 /**
  * {@inheritdoc}
  */
 public function createWithVariant()
 {
     $variant = $this->variantFactory->createNew();
     $product = $this->factory->createNew();
     $product->addVariant($variant);
     return $product;
 }
Beispiel #4
0
 /**
  * {@inheritdoc}
  */
 public function createWithCustomer(CustomerInterface $customer)
 {
     /** @var  AddressInterface $address*/
     $address = $this->decoratedFactory->createNew();
     $address->setCustomer($customer);
     return $address;
 }
 /**
  * {@inheritdoc}
  */
 public function createNew()
 {
     /** @var StaticContent $staticContent */
     $staticContent = $this->decoratedFactory->createNew();
     $staticContent->setParentDocument($this->documentManager->find(null, $this->staticContentParentPath));
     return $staticContent;
 }
Beispiel #6
0
 /**
  * {@inheritdoc}
  */
 public function generate(VariableInterface $variable)
 {
     if (!$variable->hasOptions()) {
         throw new \InvalidArgumentException('Cannot generate variants for an object without options.');
     }
     $optionSet = array();
     $optionMap = array();
     foreach ($variable->getOptions() as $k => $option) {
         foreach ($option->getValues() as $value) {
             $optionSet[$k][] = $value->getId();
             $optionMap[$value->getId()] = $value;
         }
     }
     $permutations = $this->setBuilder->build($optionSet);
     foreach ($permutations as $permutation) {
         $variant = $this->variantFactory->createNew();
         $variant->setObject($variable);
         $variant->setDefaults($variable->getMasterVariant());
         if (is_array($permutation)) {
             foreach ($permutation as $id) {
                 $variant->addOption($optionMap[$id]);
             }
         } else {
             $variant->addOption($optionMap[$permutation]);
         }
         $variable->addVariant($variant);
         $this->process($variable, $variant);
     }
 }
Beispiel #7
0
 /**
  * {@inheritdoc}
  */
 public function createForPromotion(PromotionInterface $promotion)
 {
     Assert::true($promotion->isCouponBased(), sprintf('Promotion with name %s is not coupon based.', $promotion->getName()));
     $coupon = $this->factory->createNew();
     $coupon->setPromotion($promotion);
     return $coupon;
 }
Beispiel #8
0
 /**
  * @Given the store has disabled locale :localeCode
  */
 public function theStoreHasDisabledLocale($localeCode)
 {
     $locale = $this->localeFactory->createNew();
     $locale->setCode($localeCode);
     $locale->disable();
     $this->saveLocale($locale);
 }
 /**
  * {@inheritdoc}
  */
 public function load($schemaAlias, $namespace = null, $ignoreUnknown = true)
 {
     /** @var SchemaInterface $schema */
     $schema = $this->schemaRegistry->get($schemaAlias);
     /** @var SettingsResolverInterface $resolver */
     $resolver = $this->resolverRegistry->get($schemaAlias);
     // try to resolve settings for schema alias and namespace
     $settings = $resolver->resolve($schemaAlias, $namespace);
     if (!$settings) {
         $settings = $this->settingsFactory->createNew();
         $settings->setSchemaAlias($schemaAlias);
     }
     // We need to get a plain parameters array since we use the options resolver on it
     $parameters = $settings->getParameters();
     $settingsBuilder = new SettingsBuilder();
     $schema->buildSettings($settingsBuilder);
     // Remove unknown settings' parameters (e.g. From a previous version of the settings schema)
     if (true === $ignoreUnknown) {
         foreach ($parameters as $name => $value) {
             if (!$settingsBuilder->isDefined($name)) {
                 unset($parameters[$name]);
             }
         }
     }
     $parameters = $settingsBuilder->resolve($parameters);
     $settings->setParameters($parameters);
     return $settings;
 }
Beispiel #10
0
 /**
  * {@inheritdoc}
  */
 public function createNew()
 {
     $taxon = $this->taxonFactory->createNew();
     $taxonomy = $this->translatableFactory->createNew();
     $taxonomy->setRoot($taxon);
     return $taxonomy;
 }
 /**
  * {@inheritdoc}
  */
 public function create(array $options = [])
 {
     $options = $this->optionsResolver->resolve($options);
     /** @var PromotionInterface $promotion */
     $promotion = $this->promotionFactory->createNew();
     $promotion->setCode($options['code']);
     $promotion->setName($options['name']);
     $promotion->setDescription($options['description']);
     $promotion->setCouponBased($options['coupon_based']);
     $promotion->setUsageLimit($options['usage_limit']);
     $promotion->setExclusive($options['exclusive']);
     $promotion->setPriority($options['priority']);
     if (isset($options['starts_at'])) {
         $promotion->setStartsAt(new \DateTime($options['starts_at']));
     }
     if (isset($options['ends_at'])) {
         $promotion->setEndsAt(new \DateTime($options['ends_at']));
     }
     foreach ($options['channels'] as $channel) {
         $promotion->addChannel($channel);
     }
     foreach ($options['rules'] as $rule) {
         /** @var PromotionRuleInterface $promotionRule */
         $promotionRule = $this->promotionRuleExampleFactory->create($rule);
         $promotion->addRule($promotionRule);
     }
     foreach ($options['actions'] as $action) {
         /** @var PromotionActionInterface $promotionAction */
         $promotionAction = $this->promotionActionExampleFactory->create($action);
         $promotion->addAction($promotionAction);
     }
     return $promotion;
 }
Beispiel #12
0
 /**
  * @param string $name
  */
 private function createCountryNamed($name)
 {
     /** @var CountryInterface $country */
     $country = $this->countryFactory->createNew();
     $country->setCode($this->countryNameConverter->convertToCode($name));
     $this->countryRepository->add($country);
 }
 /**
  * @param string $name
  */
 private function createCountryNamed($name)
 {
     /** @var CountryInterface $country */
     $country = $this->countryFactory->createNew();
     $country->setCode($this->getCountryCodeByEnglishCountryName($name));
     $this->countryRepository->add($country);
 }
Beispiel #14
0
 /**
  * @param array $options
  *
  * @return FormView
  */
 public function getItemFormView(array $options = array())
 {
     $cartItem = $this->cartItemFactory->createNew();
     $this->orderItemQuantityModifier->modify($cartItem, 1);
     $form = $this->formFactory->create('sylius_cart_item', $cartItem, $options);
     return $form->createView();
 }
Beispiel #15
0
 /**
  * @Given the store has disabled locale :localeName
  */
 public function theStoreHasDisabledLocale($localeName)
 {
     $locale = $this->localeFactory->createNew();
     $locale->setCode($this->localeNameConverter->convertToCode($localeName));
     $locale->disable();
     $this->sharedStorage->set('locale', $locale);
     $this->localeRepository->add($locale);
 }
Beispiel #16
0
 /**
  * {@inheritdoc}
  */
 public function createNew()
 {
     $variant = $this->variantFactory->createNew();
     $variant->setMaster(true);
     $product = $this->factory->createNew();
     $product->setMasterVariant($variant);
     return $product;
 }
 /**
  * @param string $name
  */
 private function createCustomerGroup($name)
 {
     /** @var CustomerGroupInterface $customerGroup */
     $customerGroup = $this->customerGroupFactory->createNew();
     $customerGroup->setName(ucfirst($name));
     $this->sharedStorage->set('customer_group', $customerGroup);
     $this->customerGroupRepository->add($customerGroup);
 }
 /**
  * @param PaymentSubjectInterface $payment
  *
  * @return AdjustmentInterface
  */
 private function prepareAdjustmentForOrder(PaymentSubjectInterface $payment)
 {
     $adjustment = $this->adjustmentFactory->createNew();
     $adjustment->setType(AdjustmentInterface::PAYMENT_ADJUSTMENT);
     $adjustment->setAmount($this->feeCalculator->calculate($payment));
     $adjustment->setDescription($payment->getMethod()->getName());
     return $adjustment;
 }
Beispiel #19
0
 /**
  * @param PromotionInterface $promotion
  *
  * @return AdjustmentInterface
  */
 protected function createAdjustment(PromotionInterface $promotion)
 {
     $adjustment = $this->adjustmentFactory->createNew();
     $adjustment->setType(AdjustmentInterface::PROMOTION_ADJUSTMENT);
     $adjustment->setDescription($promotion->getDescription());
     $this->originator->setOrigin($adjustment, $promotion);
     return $adjustment;
 }
Beispiel #20
0
 /**
  * @param array $options
  *
  * @return FormView
  */
 public function getItemFormView(array $options = [])
 {
     /** @var OrderItemInterface $cartItem */
     $cartItem = $this->orderItemFactory->createNew();
     $this->orderItemQuantityModifier->modify($cartItem, 1);
     $form = $this->formFactory->create(CartItemType::class, $cartItem, $options);
     return $form->createView();
 }
Beispiel #21
0
 /**
  * {@inheritdoc}
  */
 public function createWithAmountAndCurrencyCode($amount, $currencyCode)
 {
     /** @var PaymentInterface $payment */
     $payment = $this->factory->createNew();
     $payment->setAmount($amount);
     $payment->setCurrencyCode($currencyCode);
     return $payment;
 }
Beispiel #22
0
 /**
  * @param PromotionInterface $promotion
  * @param string $type
  *
  * @return AdjustmentInterface
  */
 protected function createAdjustment(PromotionInterface $promotion, $type = AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT)
 {
     $adjustment = $this->adjustmentFactory->createNew();
     $adjustment->setType($type);
     $adjustment->setLabel($promotion->getName());
     $this->originator->setOrigin($adjustment, $promotion);
     return $adjustment;
 }
Beispiel #23
0
 /**
  * @param CurrencyInterface $sourceCurrency
  * @param CurrencyInterface $targetCurrency
  * @param float $ratio
  *
  * @return ExchangeRateInterface
  */
 private function createExchangeRate(CurrencyInterface $sourceCurrency, CurrencyInterface $targetCurrency, $ratio = 1.0)
 {
     /** @var ExchangeRateInterface $exchangeRate */
     $exchangeRate = $this->exchangeRateFactory->createNew();
     $exchangeRate->setSourceCurrency($sourceCurrency);
     $exchangeRate->setTargetCurrency($targetCurrency);
     $exchangeRate->setRatio((double) $ratio);
     return $exchangeRate;
 }
 /**
  * @return OrderSequenceInterface
  */
 private function getSequence()
 {
     $sequence = $this->sequenceRepository->findOneBy([]);
     if (null === $sequence) {
         $sequence = $this->sequenceFactory->createNew();
         $this->sequenceRepository->add($sequence);
     }
     return $sequence;
 }
 /**
  * @Given /^(this product) has one review$/
  */
 public function productHasAReview(ProductInterface $product)
 {
     $review = $this->productReviewFactory->createNew();
     $review->setTitle('title');
     $review->setRating(5);
     $review->setReviewSubject($product);
     $product->addReview($review);
     $this->productReviewRepository->add($review);
 }
 /**
  * {@inheritdoc}
  */
 public function create(array $options = [])
 {
     $options = $this->optionsResolver->resolve($options);
     /** @var ProductAssociationTypeInterface $productAssociationType */
     $productAssociationType = $this->productAssociationTypeFactory->createNew();
     $productAssociationType->setName($options['name']);
     $productAssociationType->setCode($options['code']);
     return $productAssociationType;
 }
Beispiel #27
0
 /**
  * {@inheritdoc}
  */
 public function createTyped($type)
 {
     /** @var AttributeTypeInterface $attributeType */
     $attributeType = $this->attributeTypesRegistry->get($type);
     $attribute = $this->factory->createNew();
     $attribute->setType($type);
     $attribute->setStorageType($attributeType->getStorageType());
     return $attribute;
 }
 /**
  * {@inheritdoc}
  */
 public function create(array $options = [])
 {
     $options = $this->optionsResolver->resolve($options);
     /** @var Route $route */
     $route = $this->routeFactory->createNew();
     $route->setName($options['name']);
     $route->setContent($options['content']);
     return $route;
 }
Beispiel #29
0
 /**
  * {@inheritdoc}
  */
 public function createForPromotion($promotionId)
 {
     if (null === ($promotion = $this->promotionRepository->find($promotionId))) {
         throw new \InvalidArgumentException(sprintf('Promotion with id "%s" does not exist.', $promotionId));
     }
     $coupon = $this->factory->createNew();
     $coupon->setPromotion($promotion);
     return $coupon;
 }
Beispiel #30
0
 /**
  * {@inheritdoc}
  */
 public function createForSubject($subjectId)
 {
     if (null === ($subject = $this->subjectRepository->find($subjectId))) {
         throw new \InvalidArgumentException(sprintf('Review subject with id "%s" does not exist.', $subjectId));
     }
     $review = $this->factory->createNew();
     $review->setReviewSubject($subject);
     return $review;
 }