adriana/sylius-impersonator-plugin
最新稳定版本:v0.1.10
Composer 安装命令:
composer require adriana/sylius-impersonator-plugin
包简介
User Impersonator Plugin
关键字:
README 文档
README
User Impersonator Plugin
Documentation
This is a simple Sylius Plugin designed to help administrators to know when they impersonated a customer within the shop.
This hint consists in showing the string: Impersonated by {impersonator_username} in the shop banner, near the customer's name and on the checkout page.
Quickstart Installation
-
Run
composer require adriana/sylius-impersonator-plugin. -
Enable the plugin in
config/bundles.php:<?php return [ //... Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], Evo\SyliusUserImpersonatorPlugin\SyliusUserImpersonatorPlugin::class => ['all' => true], //... ]; -
Ensure you have modified resource configured in
config/packages/_sylius.yaml:imports: - { resource: "@SyliusUserImpersonatorPlugin/Resources/config/app/config.yaml" } -
Execute migrations in order to have the new field
show_user_impersonate_hintinside thechanneltable:bin/console doctrine:migrations:migrate -
Add
EvoUserImpersonatorChannelTraitin your Channel entity and implement interfaceEvoUserImpersonatorChannelInterface: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; } -
Ensure you have modified resource configured in
config/packages/_sylius.yaml:sylius_channel: resources: channel: classes: model: App\Entity\Channel\Channel -
Add translations path in order to use translations in
config/translation.yaml:framework: default_locale: '%locale%' translator: paths: - '%kernel.project_dir%/translations' - '%kernel.project_dir%/vendor/adriana/sylius-impersonator-plugin/translations' -
In order to run Behat tests ensure you have modified your
behat.ymland configured: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"
Usage
Check Admin panel, channels options - edit one channel and the Show user impersonate hint option should appear and should be enabled by default.
After that you can impersonate a customer and the Impersonated by {impersonator_username} hint should appear in the shop.
This plugin has a Twig Extension that you can use in any template you need in order to show the "impersonated by" hint. You can use this extension by calling:
{{ "sylius.user_impersonator.hint"|trans({"{{impersonator_username}}": userImpersonatorHint()}) }}
And you can also make use of the Service created in Evo\SyliusUserImpersonatorPlugin\Service\CheckUserImpersonator which you can inject into your application and call its public methods.
Run Behat Tests
Configure Services path in config/services_test.yaml:
- { resource: "../vendor/adriana/sylius-impersonator-plugin/tests/Behat/Resources/config/services.xml" }
Run tests with: APP_ENV=test vendor/bin/behat --suite=adriana_user_impersonator
统计信息
- 总下载量: 1.47k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: proprietary
- 更新时间: 2023-05-22