定制 adriana/sylius-impersonator-plugin 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

  1. Run composer require adriana/sylius-impersonator-plugin.

  2. Enable the plugin in config/bundles.php:

    <?php
    
    return [
       //...
       
       Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true],
       Evo\SyliusUserImpersonatorPlugin\SyliusUserImpersonatorPlugin::class => ['all' => true],
    
       //...
    ];
    
  3. Ensure you have modified resource configured in config/packages/_sylius.yaml:

    imports:
       - { resource: "@SyliusUserImpersonatorPlugin/Resources/config/app/config.yaml" }
    
  4. Execute migrations in order to have the new field show_user_impersonate_hint inside the channel table: bin/console doctrine:migrations:migrate

  5. Add EvoUserImpersonatorChannelTrait in your Channel entity and implement interface 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;
        }
    
  6. Ensure you have modified resource configured in config/packages/_sylius.yaml:

        sylius_channel:
            resources:
                channel:
                    classes:
                        model: App\Entity\Channel\Channel
    
  7. 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' 
    
  8. In order to run Behat tests ensure you have modified your behat.yml and 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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2023-05-22