adriana / sylius-impersonator-plugin
用户模拟插件
Requires
- php: ^8.0
- sylius/sylius: ^1.12
- symfony/webpack-encore-bundle: ^1.15
Requires (Dev)
- behat/behat: ^3.6.1
- behat/mink-selenium2-driver: ^1.4
- dmore/behat-chrome-extension: ^1.3
- dmore/chrome-mink-driver: ^2.7
- friends-of-behat/mink: ^1.8
- friends-of-behat/mink-browserkit-driver: ^1.4
- friends-of-behat/mink-debug-extension: ^2.0.0
- friends-of-behat/mink-extension: ^2.4
- friends-of-behat/page-object-extension: ^0.3
- friends-of-behat/suite-settings-extension: ^1.0
- friends-of-behat/symfony-extension: ^2.1
- friends-of-behat/variadic-extension: ^1.3
- phpspec/phpspec: ^7.2
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: ^1.8.1
- phpstan/phpstan-doctrine: 1.3.37
- phpstan/phpstan-strict-rules: ^1.3.0
- phpstan/phpstan-webmozart-assert: ^1.2.0
- phpunit/phpunit: ^9.5
- polishsymfonycommunity/symfony-mocker-container: ^1.0
- sylius-labs/coding-standard: ^4.2
- symfony/browser-kit: ^5.4 || ^6.0
- symfony/debug-bundle: ^5.4 || ^6.0
- symfony/dotenv: ^5.4 || ^6.0
- symfony/flex: ^2.2.2
- symfony/intl: ^5.4 || ^6.0
- symfony/web-profiler-bundle: ^5.4 || ^6.0
- vimeo/psalm: 5.9.0
Conflicts
- symfony/framework-bundle: 6.2.8
- dev-master
- v0.1.10
- v0.1.9
- v0.1.8
- v0.1.7
- v0.1.6
- v0.1.5
- v0.1.4
- v0.1.3
- v0.1.2
- v0.1.1
- v0.1.0
- dev-dependabot/composer/vimeo/psalm-5.14.1
- dev-fix-pipeline
- dev-use-listeners-to-impersonate-users
- dev-dependabot/composer/phpstan/phpstan-doctrine-1.3.40
- dev-use-context-provider-for-template
- dev-listeners-and-subscribers-impersonate-approach
This package is auto-updated.
Last update: 2024-09-03 14:20:44 UTC
README
用户模拟插件
文档
这是一个简单的Sylius插件,旨在帮助管理员了解他们在商店中何时模拟了客户。这个提示由在商店横幅、客户名字附近以及结账页面显示字符串“被{模拟者用户名}模拟”组成。
快速安装
-
运行
composer require adriana/sylius-impersonator-plugin
。 -
在
config/bundles.php
中启用插件<?php return [ //... Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], Evo\SyliusUserImpersonatorPlugin\SyliusUserImpersonatorPlugin::class => ['all' => true], //... ];
-
确保你已修改
config/packages/_sylius.yaml
中的资源配置imports: - { resource: "@SyliusUserImpersonatorPlugin/Resources/config/app/config.yaml" }
-
执行迁移以在
channel
表中创建新字段show_user_impersonate_hint
:bin/console doctrine:migrations:migrate
-
在你的Channel实体中添加
EvoUserImpersonatorChannelTrait
并实现接口EvoUserImpersonatorChannelInterface
namespace App\Entity\Channel; use Evo\SyliusUserImpersonatorPlugin\Entity\Channel\EvoUserImpersonatorChannelInterface; use from Evo\SyliusUserImpersonatorPlugin\Entity\Channel\EvoUserImpersonatorChannelTrait; class Channel extends BaseChannel implements EvoUserImpersonatorChannelInterface { use EvoUserImpersonatorChannelTrait; }
-
确保你已修改
config/packages/_sylius.yaml
中的资源配置sylius_channel: resources: channel: classes: model: App\Entity\Channel\Channel
-
在
config/translation.yaml
中添加翻译路径,以便使用翻译framework: default_locale: '%locale%' translator: paths: - '%kernel.project_dir%/translations' - '%kernel.project_dir%/vendor/adriana/sylius-impersonator-plugin/translations'
-
为了运行Behat测试,确保你已经修改了你的
behat.yml
并进行了配置imports: - vendor/sylius/sylius/src/Sylius/Behat/Resources/config/suites.yml - vendor/adriana/sylius-impersonator-plugin/tests/Behat/Resources/config/suites.yml . . . FriendsOfBehat\SuiteSettingsExtension: paths: - "vendor/sylius/sylius/features" - "features" - "vendor/adriana/sylius-impersonator-plugin/features"
使用方法
检查管理员面板,通道选项 - 编辑一个通道,应该会出现并默认启用的“显示用户模拟提示”选项。
之后,你可以模拟一个客户,商店中将显示“被{模拟者用户名}模拟”提示。
此插件有一个Twig扩展,您可以在任何需要的模板中使用来显示“被模拟”提示。您可以通过调用此扩展来使用它
{{ "sylius.user_impersonator.hint"|trans({"{{impersonator_username}}": userImpersonatorHint()}) }}
您还可以使用在 Evo\SyliusUserImpersonatorPlugin\Service\CheckUserImpersonator
中创建的服务,您可以将它注入到您的应用程序中并调用其公共方法。
运行Behat测试
在 config/services_test.yaml
中配置服务路径
- { resource: "../vendor/adriana/sylius-impersonator-plugin/tests/Behat/Resources/config/services.xml" }
使用: APP_ENV=test vendor/bin/behat --suite=adriana_user_impersonator
运行测试