コード例 #1
0
ファイル: PaymentContext.php プロジェクト: sylius/sylius
 /**
  * @Given /^the store allows paying (\w+) for (all channels)$/
  */
 public function storeAllowsPayingForAllChannels($paymentMethodName, array $channels)
 {
     $paymentMethod = $this->createPaymentMethod($paymentMethodName, StringInflector::nameToUppercaseCode($paymentMethodName), 'Payment method', false);
     foreach ($channels as $channel) {
         $paymentMethod->addChannel($channel);
     }
 }
コード例 #2
0
 /**
  * @param string $type
  * @param string $name
  * @param string|null $code
  *
  * @return ProductAttributeInterface
  */
 private function createProductAttribute($type, $name, $code = null)
 {
     $productAttribute = $this->productAttributeFactory->createTyped($type);
     if (null === $code) {
         $code = StringInflector::nameToUppercaseCode($name);
     }
     $productAttribute->setCode($code);
     $productAttribute->setName($name);
     return $productAttribute;
 }
コード例 #3
0
 /**
  * @param string $type
  * @param string $name
  * @param string|null $code
  */
 private function createProductAttribute($type, $name, $code = null)
 {
     $productAttribute = $this->productAttributeFactory->createTyped($type);
     if (null === $code) {
         $code = StringInflector::nameToUppercaseCode($name);
     }
     $productAttribute->setCode($code);
     $productAttribute->setName($name);
     $this->productAttributeRepository->add($productAttribute);
     $this->sharedStorage->set('product_attribute', $productAttribute);
 }
コード例 #4
0
ファイル: ProductContext.php プロジェクト: sylius/sylius
 /**
  * @param string $productName
  * @param int $price
  * @param string|null $date
  * @param ChannelInterface|null $channel
  *
  * @return ProductInterface
  */
 private function createProduct($productName, $price = 100, $date = null, ChannelInterface $channel = null)
 {
     /** @var ProductInterface $product */
     $product = $this->productFactory->createWithVariant();
     $product->setName($productName);
     $product->setCode(StringInflector::nameToUppercaseCode($productName));
     $product->setSlug($this->slugGenerator->generate($productName));
     $product->setCreatedAt(new \DateTime($date));
     /** @var ProductVariantInterface $productVariant */
     $productVariant = $this->defaultVariantResolver->getVariant($product);
     if (null === $channel && $this->sharedStorage->has('channel')) {
         $channel = $this->sharedStorage->get('channel');
     }
     if (null !== $channel) {
         $productVariant->addChannelPricing($this->createChannelPricingForChannel($price, $channel));
     }
     $productVariant->setCode($product->getCode());
     return $product;
 }
コード例 #5
0
 /**
  * @param string $productName
  *
  * @return string
  */
 private function convertToCode($productName)
 {
     return StringInflector::nameToUppercaseCode($productName);
 }
コード例 #6
0
ファイル: ProductContext.php プロジェクト: loic425/Sylius
 /**
  * @param string $productName
  * @param int $price
  *
  * @return ProductInterface
  */
 private function createProduct($productName, $price = 0, $date = null)
 {
     /** @var ProductInterface $product */
     $product = $this->productFactory->createWithVariant();
     $product->setName($productName);
     $product->setCode(StringInflector::nameToUppercaseCode($productName));
     $product->setSlug($this->slugGenerator->generate($productName));
     $product->setCreatedAt(new \DateTime($date));
     /** @var ProductVariantInterface $productVariant */
     $productVariant = $this->defaultVariantResolver->getVariant($product);
     $productVariant->setPrice($price);
     $productVariant->setCode($product->getCode());
     return $product;
 }