akki-team / sylius-settable-channel-plugin
1.0.0
2024-09-09 13:12 UTC
Requires
- php: >=8.1
- sylius/sylius: ^1.11 || ^1.12 || ^1.13
README
概述
此插件允许您通过SettableChannelContextInterface直接设置渠道上下文,使用Channel
或ChannelCode
。
在您的symfony/command
和symfony/messenger
中非常有用,在这些地方由于没有请求,无法确定渠道上下文。
查看可用于SettableChannelContextInterface的方法。
安装
- 使用以下命令将插件安装到您的项目中
$ composer require akki-team/sylius-settable-channel-plugin
- 安装后,请检查插件是否已正确声明在您的项目中的文件
config/bundles.php
中。
return [ ... Akki\SyliusSettableChannelPlugin\AkkiSyliusSettableChannelPlugin::class => ['all' => true], ];
- 现在您可以在服务中注入SettableChannelContextInterface并直接设置渠道上下文。
$this->settableChannelContext->setChannel($channel);