当前位置: 首页>>代码示例>>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;未经允许,请勿转载。