當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Factory\FactoryInterface類代碼示例

本文整理匯總了PHP中Sylius\Component\Resource\Factory\FactoryInterface的典型用法代碼示例。如果您正苦於以下問題:PHP FactoryInterface類的具體用法?PHP FactoryInterface怎麽用?PHP FactoryInterface使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了FactoryInterface類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1:

 function it_creates_a_default_united_states_channel_with_country_zone_and_usd_as_default_currency(RepositoryInterface $channelRepository, RepositoryInterface $countryRepository, RepositoryInterface $currencyRepository, RepositoryInterface $localeRepository, RepositoryInterface $zoneMemberRepository, RepositoryInterface $zoneRepository, ChannelFactoryInterface $channelFactory, FactoryInterface $countryFactory, FactoryInterface $currencyFactory, FactoryInterface $localeFactory, FactoryInterface $zoneFactory, FactoryInterface $zoneMemberFactory, ZoneMemberInterface $zoneMember, ZoneInterface $zone, ChannelInterface $channel, CountryInterface $unitedStates, CurrencyInterface $currency, LocaleInterface $locale)
 {
     $channel->getName()->willReturn('United States');
     $channelFactory->createNamed('United States')->willReturn($channel);
     $localeFactory->createNew()->willReturn($locale);
     $locale->setCode('en_US')->shouldBeCalled();
     $zoneMemberFactory->createNew()->willReturn($zoneMember);
     $zoneFactory->createNew()->willReturn($zone);
     $channel->setCode('WEB-US')->shouldBeCalled();
     $channel->setTaxCalculationStrategy('order_items_based')->shouldBeCalled();
     $zoneMember->setCode('US')->shouldBeCalled();
     $zone->setCode('US')->shouldBeCalled();
     $zone->setName('United States')->shouldBeCalled();
     $zone->setType(ZoneInterface::TYPE_COUNTRY)->shouldBeCalled();
     $zone->addMember($zoneMember)->shouldBeCalled();
     $countryFactory->createNew()->willReturn($unitedStates);
     $unitedStates->setCode('US')->shouldBeCalled();
     $currencyFactory->createNew()->willReturn($currency);
     $currency->setCode('USD')->shouldBeCalled();
     $currency->setExchangeRate(1.0)->shouldBeCalled();
     $channel->setDefaultCurrency($currency)->shouldBeCalled();
     $channel->addCurrency($currency)->shouldBeCalled();
     $channel->setDefaultLocale($locale)->shouldBeCalled();
     $channel->addLocale($locale)->shouldBeCalled();
     $currencyRepository->findOneBy(['code' => 'USD'])->willReturn(null);
     $localeRepository->findOneBy(['code' => 'en_US'])->willReturn(null);
     $currencyRepository->add($currency)->shouldBeCalled();
     $localeRepository->add($locale)->shouldBeCalled();
     $countryRepository->add($unitedStates)->shouldBeCalled();
     $channelRepository->add($channel)->shouldBeCalled();
     $zoneRepository->add($zone)->shouldBeCalled();
     $zoneMemberRepository->add($zoneMember)->shouldBeCalled();
     $this->create();
 }
開發者ID:TheMadeleine,項目名稱:Sylius,代碼行數:34,代碼來源:DefaultUnitedStatesChannelFactorySpec.php

示例2:

 function it_creates_a_cart_item_and_assigns_a_product_variant(FactoryInterface $decoratedFactory, VariantResolverInterface $variantResolver, OrderItemInterface $cartItem, ProductInterface $product, ProductVariantInterface $productVariant)
 {
     $decoratedFactory->createNew()->willReturn($cartItem);
     $variantResolver->getVariant($product)->willReturn($productVariant);
     $cartItem->setVariant($productVariant)->shouldBeCalled();
     $this->createForProduct($product)->shouldReturn($cartItem);
 }
開發者ID:ReissClothing,項目名稱:Sylius,代碼行數:7,代碼來源:CartItemFactorySpec.php

示例3:

 function it_calls_proper_factory_methods_based_on_configuration(RequestConfiguration $requestConfiguration, FactoryInterface $factory)
 {
     $requestConfiguration->getFactoryMethod()->willReturn('createNew');
     $requestConfiguration->getFactoryArguments()->willReturn(['00032']);
     $factory->createNew('00032')->willReturn(['foo', 'bar']);
     $this->create($requestConfiguration, $factory)->shouldReturn(['foo', 'bar']);
 }
開發者ID:gabiudrescu,項目名稱:Sylius,代碼行數:7,代碼來源:NewResourceFactorySpec.php

示例4:

 function it_calls_proper_method_with_arguments_based_on_configuration_when_creating_resource(FactoryInterface $factory, $configuration)
 {
     $configuration->getFactoryMethod('createNew')->willReturn('createNew');
     $configuration->getFactoryArguments(array())->willReturn(array());
     $factory->createNew()->willReturn(array('foo', 'bar'));
     $this->createResource($factory, 'createNew')->shouldReturn(array('foo', 'bar'));
 }
開發者ID:aleherse,項目名稱:Sylius,代碼行數:7,代碼來源:ResourceResolverSpec.php

示例5:

 function it_creates_a_nth_order_rule(FactoryInterface $decoratedFactory, RuleInterface $rule)
 {
     $decoratedFactory->createNew()->willReturn($rule);
     $rule->setType(NthOrderRuleChecker::TYPE)->shouldBeCalled();
     $rule->setConfiguration(['nth' => 10])->shouldBeCalled();
     $this->createNthOrder(10)->shouldReturn($rule);
 }
開發者ID:ReissClothing,項目名稱:Sylius,代碼行數:7,代碼來源:RuleFactorySpec.php

示例6:

 function it_creates_a_taxon_and_assigns_a_taxonomy_to_id(FactoryInterface $factory, RepositoryInterface $taxonomyRepository, TaxonomyInterface $taxonomy, TaxonInterface $taxon)
 {
     $factory->createNew()->willReturn($taxon);
     $taxonomyRepository->find(13)->willReturn($taxonomy);
     $taxon->setTaxonomy($taxonomy)->shouldBeCalled();
     $this->createForTaxonomy(13)->shouldReturn($taxon);
 }
開發者ID:vikey89,項目名稱:Sylius,代碼行數:7,代碼來源:TaxonFactorySpec.php

示例7:

 function it_creates_a_contains_product_rule(FactoryInterface $decoratedFactory, PromotionRuleInterface $rule)
 {
     $decoratedFactory->createNew()->willReturn($rule);
     $rule->setType(ContainsProductRuleChecker::TYPE)->shouldBeCalled();
     $rule->setConfiguration(['product_code' => 1])->shouldBeCalled();
     $this->createContainsProduct(1)->shouldReturn($rule);
 }
開發者ID:sylius,項目名稱:core,代碼行數:7,代碼來源:PromotionRuleFactorySpec.php

示例8:

 function it_creates_a_shipping_percentage_discount_action_with_a_given_discount_rate(FactoryInterface $decoratedFactory, PromotionActionInterface $promotionAction)
 {
     $decoratedFactory->createNew()->willReturn($promotionAction);
     $promotionAction->setType(ShippingPercentageDiscountPromotionActionCommand::TYPE)->shouldBeCalled();
     $promotionAction->setConfiguration(['percentage' => 0.1])->shouldBeCalled();
     $this->createShippingPercentageDiscount(0.1)->shouldReturn($promotionAction);
 }
開發者ID:sylius,項目名稱:core,代碼行數:7,代碼來源:PromotionActionFactorySpec.php

示例9:

 function it_creates_payment_with_currency_and_amout(FactoryInterface $paymentFactory, PaymentInterface $payment)
 {
     $paymentFactory->createNew()->willReturn($payment);
     $payment->setAmount(1234)->shouldBeCalled();
     $payment->setCurrency('EUR')->shouldBeCalled();
     $this->createWithAmountAndCurrency(1234, 'EUR');
 }
開發者ID:ahmadrabie,項目名稱:Sylius,代碼行數:7,代碼來源:PaymentFactorySpec.php

示例10:

 function it_creates_a_review_with_subject_and_reviewer(FactoryInterface $factory, ReviewableInterface $subject, ReviewInterface $review, ReviewerInterface $reviewer)
 {
     $factory->createNew()->willReturn($review);
     $review->setReviewSubject($subject)->shouldBeCalled();
     $review->setAuthor($reviewer)->shouldBeCalled();
     $this->createForSubjectWithReviewer($subject, $reviewer);
 }
開發者ID:loic425,項目名稱:Sylius,代碼行數:7,代碼來源:ReviewFactorySpec.php

示例11:

 function it_creates_new_product_with_variant(FactoryInterface $factory, FactoryInterface $variantFactory, ProductInterface $product, ProductVariantInterface $variant)
 {
     $variantFactory->createNew()->willReturn($variant);
     $factory->createNew()->willReturn($product);
     $product->addVariant($variant)->shouldBeCalled();
     $this->createWithVariant()->shouldReturn($product);
 }
開發者ID:TheMadeleine,項目名稱:Sylius,代碼行數:7,代碼來源:ProductFactorySpec.php

示例12: createCountryNamed

 /**
  * @param string $name
  */
 private function createCountryNamed($name)
 {
     /** @var CountryInterface $country */
     $country = $this->countryFactory->createNew();
     $country->setCode($this->getCountryCodeByEnglishCountryName($name));
     $this->countryRepository->add($country);
 }
開發者ID:stevedien,項目名稱:Sylius,代碼行數:10,代碼來源:GeographicalContext.php

示例13: createTaxon

 /**
  * @param string $name
  *
  * @return TaxonInterface
  */
 private function createTaxon($name)
 {
     $taxon = $this->taxonFactory->createNew();
     $taxon->setName($name);
     $taxon->setCode($this->getCodeFromName($name));
     return $taxon;
 }
開發者ID:Mozan,項目名稱:Sylius,代碼行數:12,代碼來源:TaxonomyContext.php

示例14: generate

 /**
  * {@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);
     }
 }
開發者ID:aleherse,項目名稱:Sylius,代碼行數:32,代碼來源:VariantGenerator.php

示例15: createNew

 /**
  * {@inheritdoc}
  */
 public function createNew()
 {
     /** @var Route $route */
     $route = $this->decoratedFactory->createNew();
     $route->setParentDocument($this->documentManager->find(null, $this->routeParentPath));
     return $route;
 }
開發者ID:ReissClothing,項目名稱:Sylius,代碼行數:10,代碼來源:RouteFactory.php


注:本文中的Sylius\Component\Resource\Factory\FactoryInterface類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。