adriana / sylius-impersonator-plugin
User Impersonator Plugin
Installs: 628
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 4
Type:sylius-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-11-03 14:38:03 UTC
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_hint
inside thechannel
table:bin/console doctrine:migrations:migrate
-
Add
EvoUserImpersonatorChannelTrait
in 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.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