本文整理汇总了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) {
}
}
示例2: getAvailableCurrencies
/**
* {@inheritdoc}
*/
public function getAvailableCurrencies()
{
$currentChannel = $this->channelContext->getChannel();
return $currentChannel->getCurrencies()->filter(function (CurrencyInterface $currency) {
return $currency->isEnabled();
});
}
示例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());
}
示例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());
}
示例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;
}
示例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()];
}
示例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));
}
示例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);
}
}
示例9: getDefaultLocaleCode
/**
* {@inheritdoc}
*/
public function getDefaultLocaleCode()
{
try {
/** @var ChannelInterface $channel */
$channel = $this->channelContext->getChannel();
return $channel->getDefaultLocale()->getCode();
} catch (ChannelNotFoundException $exception) {
return $this->defaultLocaleCode;
}
}
示例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();
}
示例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];
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例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;
}