private function configureChannel(ChannelInterface $channel, $localeCodes = null, $currencyCodes = null, $shippingMethodNames = null, $paymentMethodNames = null, $taxonomyNames = null) { if ($shippingMethodNames) { $shippingMethodNames = array_map('trim', explode(',', $shippingMethodNames)); foreach ($shippingMethodNames as $shippingMethodName) { $shippingMethod = $shippingMethods = $this->getRepository('shipping_method')->findOneBy(array('name' => $shippingMethodName)); $channel->addShippingMethod($shippingMethod); } } if ($paymentMethodNames) { $paymentMethodNames = array_map('trim', explode(',', $paymentMethodNames)); $paymentMethods = $this->getRepository('payment_method')->findBy(array('name' => $paymentMethodNames)); foreach ($paymentMethods as $paymentMethod) { $channel->addPaymentMethod($paymentMethod); } } if ($localeCodes) { $localeCodes = array_map('trim', explode(',', $localeCodes)); $locales = $this->getRepository('locale')->findBy(array('code' => $localeCodes)); foreach ($locales as $locale) { $channel->addLocale($locale); } } if ($currencyCodes) { $currencyCodes = array_map('trim', explode(',', $currencyCodes)); $currencies = $this->getRepository('currency')->findBy(array('code' => $currencyCodes)); foreach ($currencies as $currency) { $channel->addCurrency($currency); } } if ($taxonomyNames) { $taxonomyNames = array_map('trim', explode(',', $taxonomyNames)); foreach ($taxonomyNames as $taxonomyName) { $taxonomy = $this->getRepository('taxonomy')->findOneBy(array('name' => $taxonomyName)); $channel->addTaxonomy($taxonomy); } } }
/** * @Given /^(it) uses the "([^"]+)" currency by default$/ */ public function itUsesTheCurrencyByDefault(ChannelInterface $channel, $currencyCode) { $currency = $this->provideCurrency($currencyCode); $currency->setExchangeRate(1.0); $this->currencyManager->flush(); $channel->addCurrency($currency); $channel->setDefaultCurrency($currency); $this->channelManager->flush(); }
/** * @Given /^(that channel)(?: also|) allows to shop using the "([^"]+)" currency$/ * @Given /^(that channel)(?: also|) allows to shop using "([^"]+)" and "([^"]+)" currencies$/ * @Given /^(that channel)(?: also|) allows to shop using "([^"]+)", "([^"]+)" and "([^"]+)" currencies$/ */ public function thatChannelAllowsToShopUsingAndCurrencies(ChannelInterface $channel, ...$currenciesCodes) { foreach ($currenciesCodes as $currencyCode) { $channel->addCurrency($this->provideCurrency($currencyCode)); } $this->channelManager->flush(); }
/** * @Given /^(that channel)(?: also|) allows to shop using the "([^"]+)" currency with exchange rate ([0-9\.]+)$/ */ public function thatChannelAllowsToShopUsingCurrency(ChannelInterface $channel, $currencyCode, $exchangeRate = 1.0) { $currency = $this->createCurrency($currencyCode, $exchangeRate); $channel->addCurrency($currency); $this->saveCurrency($currency); $this->channelManager->flush(); }