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


PHP ChannelContextInterface::getChannel方法代碼示例

本文整理匯總了PHP中Sylius\Component\Channel\Context\ChannelContextInterface::getChannel方法的典型用法代碼示例。如果您正苦於以下問題:PHP ChannelContextInterface::getChannel方法的具體用法?PHP ChannelContextInterface::getChannel怎麽用?PHP ChannelContextInterface::getChannel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Sylius\Component\Channel\Context\ChannelContextInterface的用法示例。


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

示例1: collect

 /**
  * {@inheritdoc}
  */
 public function collect(Request $request, Response $response, \Exception $exception = null)
 {
     try {
         $this->data['channel'] = $this->channelContext->getChannel();
     } catch (ChannelNotFoundException $exception) {
     }
 }
開發者ID:ReissClothing,項目名稱:Sylius,代碼行數:10,代碼來源:ChannelCollector.php

示例2: getAvailableCurrencies

 /**
  * {@inheritdoc}
  */
 public function getAvailableCurrencies()
 {
     $currentChannel = $this->channelContext->getChannel();
     return $currentChannel->getCurrencies()->filter(function (CurrencyInterface $currency) {
         return $currency->isEnabled();
     });
 }
開發者ID:okwinza,項目名稱:Sylius,代碼行數:10,代碼來源:ChannelAwareCurrencyProvider.php

示例3: processOrderChannel

 /**
  * @param GenericEvent $event
  */
 public function processOrderChannel(GenericEvent $event)
 {
     $order = $event->getSubject();
     if (!$order instanceof OrderInterface) {
         throw new UnexpectedTypeException($order, 'Sylius\\Component\\Core\\Model\\OrderInterface');
     }
     $order->setChannel($this->channelContext->getChannel());
 }
開發者ID:Strontium-90,項目名稱:Sylius,代碼行數:11,代碼來源:OrderChannelListener.php

示例4: processOrderChannel

 /**
  * @param GenericEvent $event
  */
 public function processOrderChannel(GenericEvent $event)
 {
     $order = $event->getSubject();
     if (!$order instanceof OrderInterface) {
         throw new UnexpectedTypeException($order, OrderInterface::class);
     }
     $order->setChannel($this->channelContext->getChannel());
 }
開發者ID:Silwereth,項目名稱:Sylius,代碼行數:11,代碼來源:OrderChannelListener.php

示例5: getCurrencyCode

 /**
  * {@inheritdoc}
  */
 public function getCurrencyCode()
 {
     $availableCurrenciesCodes = $this->currencyProvider->getAvailableCurrenciesCodes();
     $currencyCode = $this->currencyStorage->get($this->channelContext->getChannel());
     if (!in_array($currencyCode, $availableCurrenciesCodes, true)) {
         throw CurrencyNotFoundException::notAvailable($currencyCode, $availableCurrenciesCodes);
     }
     return $currencyCode;
 }
開發者ID:loic425,項目名稱:Sylius,代碼行數:12,代碼來源:StorageBasedCurrencyContext.php

示例6: calculate

 /**
  * @param PriceableInterface $subject
  * @param array              $configuration
  * @param array              $context
  *
  * @return int
  */
 public function calculate(PriceableInterface $subject, array $configuration, array $context = [])
 {
     $currentChannel = $this->channelContext->getChannel();
     $calculatorConfiguration = $subject->getPricingConfiguration();
     if (!isset($calculatorConfiguration[$currentChannel->getId()])) {
         return $subject->getPrice();
     }
     return $calculatorConfiguration[$currentChannel->getId()];
 }
開發者ID:ahmadrabie,項目名稱:Sylius,代碼行數:16,代碼來源:ChannelBasedCalculator.php

示例7: handle

 /**
  * {@inheritdoc}
  */
 public function handle($code)
 {
     try {
         $this->localeStorage->set($this->channelContext->getChannel(), $code);
     } catch (ChannelNotFoundException $exception) {
         throw new HandleException(self::class, 'Sylius cannot found the channel', $exception);
     }
     $this->eventDispatcher->dispatch(SyliusLocaleEvents::CODE_CHANGED, new GenericEvent($code));
 }
開發者ID:origammi,項目名稱:Sylius,代碼行數:12,代碼來源:ShopLocaleChangeHandler.php

示例8: getDefaultCurrencyCode

 /**
  * {@inheritdoc}
  */
 public function getDefaultCurrencyCode()
 {
     try {
         /** @var ChannelInterface $channel */
         $channel = $this->channelContext->getChannel();
         return $channel->getBaseCurrency()->getCode();
     } catch (ChannelNotFoundException $exception) {
         throw new CurrencyNotFoundException(null, $exception);
     }
 }
開發者ID:sylius,項目名稱:core,代碼行數:13,代碼來源:ChannelBasedCurrencyProvider.php

示例9: getDefaultLocaleCode

 /**
  * {@inheritdoc}
  */
 public function getDefaultLocaleCode()
 {
     try {
         /** @var ChannelInterface $channel */
         $channel = $this->channelContext->getChannel();
         return $channel->getDefaultLocale()->getCode();
     } catch (ChannelNotFoundException $exception) {
         return $this->defaultLocaleCode;
     }
 }
開發者ID:TeamNovatek,項目名稱:Sylius,代碼行數:13,代碼來源:ChannelBasedLocaleProvider.php

示例10: setCurrencyCode

 /**
  * {@inheritdoc}
  */
 public function setCurrencyCode($currencyCode)
 {
     if (null === ($customer = $this->customerContext->getCustomer())) {
         $channel = $this->channelContext->getChannel();
         return $this->storage->setData($this->getStorageKey($channel->getCode()), $currencyCode);
     }
     $customer->setCurrencyCode($currencyCode);
     $this->customerManager->persist($customer);
     $this->customerManager->flush();
 }
開發者ID:okwinza,項目名稱:Sylius,代碼行數:13,代碼來源:CurrencyContext.php

示例11: getChannel

 /**
  * {@inheritdoc}
  */
 public function getChannel()
 {
     $objectIdentifier = $this->requestStack->getMasterRequest();
     if (null === $objectIdentifier) {
         return $this->decoratedChannelContext->getChannel();
     }
     if (!isset($this->requestToChannelMap[$objectIdentifier])) {
         $this->requestToChannelMap[$objectIdentifier] = $this->decoratedChannelContext->getChannel();
     }
     return $this->requestToChannelMap[$objectIdentifier];
 }
開發者ID:ahmadrabie,項目名稱:Sylius,代碼行數:14,代碼來源:CachedPerRequestChannelContext.php

示例12: getTheme

 /**
  * {@inheritdoc}
  */
 public function getTheme()
 {
     try {
         /** @var ChannelInterface $channel */
         $channel = $this->channelContext->getChannel();
         return $channel->getTheme();
     } catch (ChannelNotFoundException $exception) {
         return null;
     } catch (\Exception $exception) {
         return null;
     }
 }
開發者ID:ahmadrabie,項目名稱:Sylius,代碼行數:15,代碼來源:ChannelBasedThemeContext.php

示例13: getTheme

 /**
  * {@inheritdoc}
  */
 public function getTheme()
 {
     try {
         /** @var ChannelInterface $channel */
         $channel = $this->channelContext->getChannel();
         return $this->themeRepository->findOneByName($channel->getThemeName());
     } catch (ChannelNotFoundException $exception) {
         return null;
     } catch (\Exception $exception) {
         return null;
     }
 }
開發者ID:ReissClothing,項目名稱:Sylius,代碼行數:15,代碼來源:ChannelBasedThemeContext.php

示例14: getEnabledLocalesCodes

 /**
  * @return string[]
  */
 protected function getEnabledLocalesCodes()
 {
     $localesCodes = [];
     /** @var LocaleInterface[] $locales */
     $locales = $this->channelContext->getChannel()->getLocales();
     foreach ($locales as $locale) {
         if (!$locale->isEnabled()) {
             continue;
         }
         $localesCodes[] = $locale->getCode();
     }
     return $localesCodes;
 }
開發者ID:ahmadrabie,項目名稱:Sylius,代碼行數:16,代碼來源:ChannelAwareLocaleProvider.php

示例15: getLocaleCode

 /**
  * {@inheritdoc}
  */
 public function getLocaleCode()
 {
     $availableLocalesCodes = $this->localeProvider->getAvailableLocalesCodes();
     try {
         $localeCode = $this->localeStorage->get($this->channelContext->getChannel());
     } catch (ChannelNotFoundException $exception) {
         throw new LocaleNotFoundException(null, $exception);
     }
     if (!in_array($localeCode, $availableLocalesCodes, true)) {
         throw LocaleNotFoundException::notAvailable($localeCode, $availableLocalesCodes);
     }
     return $localeCode;
 }
開發者ID:ReissClothing,項目名稱:Sylius,代碼行數:16,代碼來源:StorageBasedLocaleContext.php


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