本文整理汇总了PHP中Sylius\Component\Channel\Context\ChannelContextInterface类的典型用法代码示例。如果您正苦于以下问题:PHP ChannelContextInterface类的具体用法?PHP ChannelContextInterface怎么用?PHP ChannelContextInterface使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ChannelContextInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function it_proccess_order_channel_successfully(GenericEvent $event, OrderInterface $order, ChannelContextInterface $channelContext, ChannelInterface $channel)
{
$event->getSubject()->shouldBeCalled()->willReturn($order);
$channelContext->getChannel()->shouldBeCalled()->willReturn($channel);
$order->setChannel($channel)->shouldBeCalled();
$this->processOrderChannel($event);
}
示例2:
function it_does_not_cache_results_while_there_are_no_master_requests(ChannelContextInterface $decoratedChannelContext, RequestStack $requestStack, ChannelInterface $firstChannel, ChannelInterface $secondChannel)
{
$requestStack->getMasterRequest()->willReturn(null, null);
$decoratedChannelContext->getChannel()->willReturn($firstChannel, $secondChannel)->shouldBeCalledTimes(2);
$this->getChannel()->shouldReturn($firstChannel);
$this->getChannel()->shouldReturn($secondChannel);
}
示例3:
function it_does_not_cache_channel_not_found_exceptions_for_null_master_requests(ChannelContextInterface $decoratedChannelContext, RequestStack $requestStack, ChannelInterface $channel)
{
$requestStack->getMasterRequest()->willReturn(null, null);
$decoratedChannelContext->getChannel()->will(CompositePromise::it()->willThrow(ChannelNotFoundException::class)->andThenReturn($channel))->shouldBeCalledTimes(2);
$this->shouldThrow(ChannelNotFoundException::class)->during('getChannel');
$this->getChannel()->shouldReturn($channel);
}
示例4:
function it_throws_an_exception_if_currency_taken_from_storage_is_not_available(ChannelContextInterface $channelContext, CurrencyStorageInterface $currencyStorage, CurrencyProviderInterface $currencyProvider, ChannelInterface $channel)
{
$channelContext->getChannel()->willReturn($channel);
$currencyStorage->get($channel)->willReturn('BTC');
$currencyProvider->getAvailableCurrenciesCodes()->willReturn(['LTC', 'PLN']);
$this->shouldThrow(CurrencyNotFoundException::class)->during('getCurrencyCode');
}
示例5: GenericEvent
function it_throws_handle_exception_if_channel_was_not_found(LocaleStorageInterface $localeStorage, ChannelContextInterface $channelContext, EventDispatcherInterface $eventDispatcher)
{
$channelContext->getChannel()->willThrow(ChannelNotFoundException::class);
$localeStorage->set(Argument::any(), Argument::any())->shouldNotBeCalled();
$eventDispatcher->dispatch(SyliusLocaleEvents::CODE_CHANGED, new GenericEvent('en_GB'))->shouldNotBeCalled();
$this->shouldThrow(HandleException::class)->during('handle', ['en_GB']);
}
示例6:
function it_throws_an_exception_if_locale_taken_from_storage_is_not_available(ChannelContextInterface $channelContext, LocaleStorageInterface $localeStorage, LocaleProviderInterface $localeProvider, ChannelInterface $channel)
{
$channelContext->getChannel()->willReturn($channel);
$localeStorage->get($channel)->willReturn('pl_PL');
$localeProvider->getAvailableLocalesCodes()->willReturn(['en_US', 'en_UK']);
$this->shouldThrow(LocaleNotFoundException::class)->during('getLocaleCode');
}
示例7:
function it_handles_shop_currency_code_change(CurrencyStorageInterface $currencyStorage, ChannelContextInterface $channelContext, EventDispatcherInterface $eventDispatcher, ChannelInterface $channel)
{
$channelContext->getChannel()->willReturn($channel);
$currencyStorage->set($channel, 'USD')->shouldBeCalled();
$eventDispatcher->dispatch(SyliusCurrencyEvents::CODE_CHANGED, Argument::type(GenericEvent::class))->shouldBeCalled();
$this->handle('USD');
}
示例8:
function it_clears_cart_session_after_logging_out_and_return_default_handler_response(ChannelContextInterface $channelContext, ChannelInterface $channel, HttpUtils $httpUtils, Request $request, Response $response, SessionInterface $session)
{
$channelContext->getChannel()->willReturn($channel);
$channel->getCode()->willReturn('WEB_US');
$session->remove('_sylius.cart.WEB_US')->shouldBeCalled();
$httpUtils->createRedirectResponse($request, '/')->willReturn($response);
$this->onLogoutSuccess($request)->shouldReturn($response);
}
示例9: __construct
/**
* @param ChannelRepositoryInterface $channelRepository
* @param ChannelContextInterface $channelContext
*/
public function __construct(ChannelRepositoryInterface $channelRepository, ChannelContextInterface $channelContext)
{
$this->data['channels'] = $channelRepository->findAll();
try {
$this->data['current_channel'] = $channelContext->getChannel();
} catch (ChannelNotFoundException $exception) {
$this->data['current_channel'] = null;
}
}
示例10:
function its_nested_request_resolvers_can_have_priority(ChannelContextInterface $firstChannelContext, ChannelContextInterface $secondChannelContext, ChannelContextInterface $thirdChannelContext, ChannelInterface $channel)
{
$firstChannelContext->getChannel()->shouldNotBeCalled();
$secondChannelContext->getChannel()->willReturn($channel);
$thirdChannelContext->getChannel()->willThrow(ChannelNotFoundException::class);
$this->addContext($firstChannelContext, -5);
$this->addContext($secondChannelContext, 0);
$this->addContext($thirdChannelContext, 5);
$this->getChannel()->shouldReturn($channel);
}
示例11:
function it_sends_an_email_registration_successfully(SenderInterface $emailSender, ChannelContextInterface $channelContext, GenericEvent $event, CustomerInterface $customer, ShopUserInterface $user, ChannelInterface $channel)
{
$event->getSubject()->willReturn($customer);
$customer->getUser()->willReturn($user);
$customer->getEmail()->willReturn('fulanito@sylius.com');
$user->getEmail()->willReturn('fulanito@sylius.com');
$channelContext->getChannel()->willReturn($channel);
$emailSender->send(Emails::USER_REGISTRATION, ['fulanito@sylius.com'], ['user' => $user])->shouldBeCalled();
$this->sendUserRegistrationEmail($event);
}
示例12: getAvailableCurrencies
/**
* {@inheritdoc}
*/
public function getAvailableCurrencies()
{
$currentChannel = $this->channelContext->getChannel();
return $currentChannel->getCurrencies()->filter(function (CurrencyInterface $currency) {
return $currency->isEnabled();
});
}
示例13: collect
/**
* {@inheritdoc}
*/
public function collect(Request $request, Response $response, \Exception $exception = null)
{
try {
$this->data['channel'] = $this->channelContext->getChannel();
} catch (ChannelNotFoundException $exception) {
}
}
示例14: 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());
}
示例15: 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());
}