/** * @param string $name * * @return TaxonInterface */ private function createTaxon($name) { $taxon = $this->taxonFactory->createNew(); $taxon->setName($name); $taxon->setCode($this->getCodeFromName($name)); return $taxon; }
/** * {@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; }
/** * {@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; }
/** * {@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); } }
/** * {@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; }
/** * @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; }
/** * {@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; }
/** * @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); }
/** * @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(); }
/** * @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); }
/** * {@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; }
/** * @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; }
/** * @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(); }
/** * {@inheritdoc} */ public function createWithAmountAndCurrencyCode($amount, $currencyCode) { /** @var PaymentInterface $payment */ $payment = $this->factory->createNew(); $payment->setAmount($amount); $payment->setCurrencyCode($currencyCode); return $payment; }
/** * @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; }
/** * @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; }
/** * {@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; }
/** * {@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; }
/** * {@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; }