diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index c599c947..950b44ea 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -21,19 +21,12 @@ jobs:
strategy:
fail-fast: false
matrix:
- php: ["8.0", "8.1", "8.2", "8.3"]
- symfony: ["^5.4", "^6.4"]
- sylius: ["~1.12.0", "~1.13.0", "~1.14.0"]
- node: ["^18.0", "^20.0"]
- mysql: ["8.0"]
- exclude:
- - sylius: "~1.13.0"
- php: 8.0
- - sylius: "~1.14.0"
- php: 8.0
- - sylius: "~1.12.0"
- php: 8.0
- symfony: ^6.4
+ php: [ "8.2", "8.3" ]
+ symfony: [ "^6.4", "^7.1" ]
+ sylius: [ "~2.0.0" ]
+ node: [ "20.x" ]
+ mysql: ["8.4"]
+ state_machine_adapter: ["symfony_workflow"]
env:
APP_ENV: test
@@ -184,7 +177,7 @@ jobs:
-
name: Upload Behat logs
- uses: actions/upload-artifact@v3
+ uses: actions/upload-artifact@v4
if: failure()
with:
name: Behat logs
diff --git a/.github/workflows/coding_standard.yml b/.github/workflows/coding_standard.yml
index e0a943cd..b629a1d0 100644
--- a/.github/workflows/coding_standard.yml
+++ b/.github/workflows/coding_standard.yml
@@ -18,19 +18,10 @@ jobs:
strategy:
fail-fast: false
matrix:
- php: [ "8.0", "8.1", "8.2", "8.3" ]
- symfony: [ "^5.4", "^6.4" ]
- sylius: ["~1.12.0", "~1.13.0", "~1.14.0"]
- node: [ "18.x", "20.x" ]
-
- exclude:
- - sylius: "~1.13.0"
- php: 8.0
- - sylius: "~1.14.0"
- php: 8.0
- - sylius: "~1.12.0"
- php: 8.0
- symfony: ^6.4
+ php: [ "8.2", "8.3" ]
+ symfony: [ "^6.4", "^7.1" ]
+ sylius: [ "~2.0.0" ]
+ node: [ "20.x" ]
steps:
- uses: actions/checkout@v3
diff --git a/.gitignore b/.gitignore
index f486a1fb..b4756ad4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,4 @@
/behat.yml
/phpspec.yml
/phpunit.xml
+.idea
diff --git a/UPGRADE-2.0.md b/UPGRADE-2.0.md
new file mode 100644
index 00000000..68f76d76
--- /dev/null
+++ b/UPGRADE-2.0.md
@@ -0,0 +1,239 @@
+# UPGRADE FROM 1.X TO 2.0
+
+## General Changes
+
+1. **Support for Sylius 2.0**: The plugin is now fully compatible with Sylius 2.0 and is the recommended version to use.
+2. **Dropped Support for Sylius 1.X**: Applications must be upgraded to [Sylius 2.0](https://github.com/Sylius/Sylius/blob/2.0/UPGRADE-2.0.md) to continue using this plugin.
+3. **PHP Compatibility**: The minimum supported PHP version has been increased to **8.2**.
+
+## Structural Changes
+
+### Directory Structure Updates
+
+Following Symfony's latest recommendations, the directory structure has been updated:
+
+- `@SyliusBlacklistPlugin/Resources/assets` → `@SyliusBlacklistPlugin/assets`
+- `@SyliusBlacklistPlugin/Resources/config` → `@SyliusBlacklistPlugin/config`
+- `@SyliusBlacklistPlugin/Resources/translations` → `@SyliusBlacklistPlugin/translations`
+- `@SyliusBlacklistPlugin/Resources/views` → `@SyliusBlacklistPlugin/templates`
+
+## Service Modifications
+
+1. Several services have been modified to align with Sylius 2.0's structure. For example:
+ ```xml
+
+ %bitbag.sylius_blacklist_plugin.automatic_blacklisting_rules%
+ %bitbag_sylius_blacklist_plugin.model.automatic_blacklisting_configuration.class%
+ %bitbag.sylius_blacklist_plugin.form.type.validation_groups%
+
+
+
+
+
+ %sylius.model.order.class%
+ %bitbag.sylius_blacklist_plugin.form.type.checkout_address.validation_groups%
+
+
+
+
+
+ %sylius.model.customer.class%
+
+
+
+
+
+
+
+
+
+
+
+
+ %bitbag.sylius_blacklist_plugin.automatic_blacklisting_rules%
+
+
+
+ (...)
+ ```
+
+2. Additional service modifications (template downloaded from twig_hooks):
+
+ ```xml
+
+
+
+ %bitbag_sylius_blacklist_plugin.model.automatic_blacklisting_configuration.class%
+ BitBag\SyliusBlacklistPlugin\Form\Type\AutomaticBlacklistingConfigurationType
+
+
+
+
+
+
+ %bitbag_sylius_blacklist_plugin.model.blacklisting_rule.class%
+ BitBag\SyliusBlacklistPlugin\Form\Type\BlacklistingRuleType
+
+
+
+
+
+
+ %bitbag_sylius_blacklist_plugin.model.fraud_suspicion.class%
+ BitBag\SyliusBlacklistPlugin\Form\Type\FraudSuspicionType
+
+
+ ```
+
+3. **Container Service Visibility Changes**: The visibility of services has been set to `private` by default, following Symfony best practices. Services used in controllers and event listeners remain public where necessary.
+
+
+## Routing Updates
+
+1. The route **bitbag_sylius_blacklist_plugin_admin_fraud_suspicion_show** has been replaced with **sylius_admin_fraud_suspicion_show**. Update your routes configuration accordingly:
+
+```yaml
+sylius_admin_fraud_suspicion_show:
+ path: /admin/fraud-suspicion/{id}
+ controller: BitBag\SyliusBlacklistPlugin\Controller\FraudSuspicionController::showAction
+```
+
+## Admin Panel Adjustments
+
+1. **No need to overwrite templates**:
+ Thanks to the use of Twig Hooks and the refactoring of templates, you no longer need to overwrite templates to use plugin features.
+
+## Twig Hook Integrations
+
+```yaml
+sylius_twig_hooks:
+ hooks:
+ 'sylius_admin.automatic_blacklisting_configuration.create.content':
+ form:
+ component: 'sylius_admin:automatic_blacklisting_configuration:form'
+ props:
+ resource: '@=_context.resource'
+ form: '@=_context.form'
+ template: '@BitBagSyliusBlacklistPlugin/AutomaticBlacklistingConfiguration/Admin/form.html.twig'
+ configuration:
+ render_rest: false
+```
+
+More Twig Hooks are available for different contexts, including:
+
+- `sylius_admin.automatic_blacklisting_configuration.update.content`
+- `sylius_admin.blacklisting_rule.create.content`
+- `sylius_admin.blacklisting_rule.update.content`
+- `sylius_admin.fraud_suspicion.create.content`
+- `sylius_admin.fraud_suspicion.update.content`
+- `sylius_admin.fraud_suspicion.show.content`
+
+## Overwritten Sylius Templates
+
+```yaml
+sylius_twig_hooks:
+ hooks:
+ 'sylius_admin.customer.update.content.form.sections#right':
+ extra_information:
+ template: '@BitBagSyliusBlacklistPlugin/Customer/Form/Sections/extra_information.html.twig'
+ priority: 0
+
+sylius_twig_hooks:
+ hooks:
+ 'sylius_admin.customer.update.content.form.sections#right':
+ extra_information:
+ template: '@BitBagSyliusBlacklistPlugin/Customer/Form/Sections/extra_information.html.twig'
+ priority: 0
+
+sylius_twig_hooks:
+ hooks:
+ 'sylius_admin.order.show.content.header.title_block':
+ title:
+ template: '@SyliusAdmin/order/show/content/header/title_block/title.html.twig'
+ priority: 100
+ actions:
+ template: '@BitBagSyliusBlacklistPlugin/Order/Show/Content/Header/Title_block/actions.html.twig'
+ priority: 0
+```
+
+## Configuration Updates
+
+1. **Winzou State Machine Removed**:
+ - The Winzou State Machine has been completely removed.
+ - Instead, the **Symfony Workflow** component has been introduced for managing state transitions.
+ - Update your configuration to use `workflow` instead of `state_machine`.
+
+ Example:
+ ```yaml
+ framework:
+ workflows:
+ !php/const BitBag\SyliusBlacklistPlugin\Transitions\CustomerTransitions::GRAPH:
+ type: state_machine
+ marking_store:
+ property: fraudStatus
+ type: method
+ supports:
+ - BitBag\SyliusBlacklistPlugin\Entity\Customer\FraudStatusInterface
+ initial_marking:
+ !php/const BitBag\SyliusBlacklistPlugin\Entity\Customer\FraudStatusInterface::FRAUD_STATUS_NEUTRAL
+ places:
+ - !php/const BitBag\SyliusBlacklistPlugin\Entity\Customer\FraudStatusInterface::FRAUD_STATUS_NEUTRAL
+ - !php/const BitBag\SyliusBlacklistPlugin\Entity\Customer\FraudStatusInterface::FRAUD_STATUS_BLACKLISTED
+ - !php/const BitBag\SyliusBlacklistPlugin\Entity\Customer\FraudStatusInterface::FRAUD_STATUS_WHITELISTED
+ transitions:
+ !php/const BitBag\SyliusBlacklistPlugin\Transitions\CustomerTransitions::TRANSITION_NEUTRALIZING_PROCESS:
+ from:
+ - !php/const BitBag\SyliusBlacklistPlugin\Entity\Customer\FraudStatusInterface::FRAUD_STATUS_BLACKLISTED
+ to:
+ - !php/const BitBag\SyliusBlacklistPlugin\Entity\Customer\FraudStatusInterface::FRAUD_STATUS_NEUTRAL
+ !php/const BitBag\SyliusBlacklistPlugin\Transitions\CustomerTransitions::TRANSITION_BLACKLISTING_PROCESS:
+ from:
+ - !php/const BitBag\SyliusBlacklistPlugin\Entity\Customer\FraudStatusInterface::FRAUD_STATUS_NEUTRAL
+ to:
+ - !php/const BitBag\SyliusBlacklistPlugin\Entity\Customer\FraudStatusInterface::FRAUD_STATUS_BLACKLISTED
+ !php/const BitBag\SyliusBlacklistPlugin\Transitions\CustomerTransitions::TRANSITION_WHITELISTING_PROCESS:
+ from:
+ - !php/const BitBag\SyliusBlacklistPlugin\Entity\Customer\FraudStatusInterface::FRAUD_STATUS_NEUTRAL
+ to:
+ - !php/const BitBag\SyliusBlacklistPlugin\Entity\Customer\FraudStatusInterface::FRAUD_STATUS_WHITELISTED
+ ```
+
+## Removed Features
+
+1. **Legacy Support Removed**:
+ - Removed compatibility layers for Sylius 1.X.
+ - Dropped support for deprecated interfaces and methods in Sylius 2.0.
+
+## How to Upgrade
+
+1. Ensure your application is upgraded to Sylius 2.0:
+ ```bash
+ composer require sylius/sylius:~2.0.0 --no-update
+ ```
+2. To update the plugin, run the following command:
+ ```bash
+ composer require bitbag/blacklist-plugin:^2.0 --no-update
+ ```
+3. To ensure proper routing configuration, update the path in your Symfony project:
+
+ Replace the following:
+ ```
+ bitbag_sylius_blacklist_plugin:
+ resource: "@BitBagSyliusBlacklistPlugin/Resources/config/routing.yaml"
+ ```
+
+ With:
+ ```
+ bitbag_sylius_blacklist_plugin:
+ resource: "@BitBagSyliusBlacklistPlugin/config/routing.yaml"
+ ```
+3. Update your dependencies:
+ ```bash
+ composer update
+ ```
+4. Verify your routes and service configurations as described above.
+5. Verify your templates and hooks for any required adjustments.
+
+After completing these steps, your Sylius Blacklist Plugin should be fully functional with Sylius 2.0.
+
diff --git a/UPGRADE.md b/UPGRADE.md
deleted file mode 100644
index 8c28fbab..00000000
--- a/UPGRADE.md
+++ /dev/null
@@ -1,122 +0,0 @@
-# UPGRADE FROM `v1.3.X` TO `v1.4.0`
-
-First step is upgrading Sylius with composer
-
-- `composer require sylius/sylius:~1.4.0`
-
-### Test application database
-
-#### Migrations
-
-If you provide migrations with your plugin, take a look at following changes:
-
-* Change base `AbstractMigration` namespace to `Doctrine\Migrations\AbstractMigration`
-* Add `: void` return types to both `up` and `down` functions
-
-#### Schema update
-
-If you don't use migrations, just run `(cd tests/Application && bin/console doctrine:schema:update --force)` to update the test application's database schema.
-
-### Dotenv
-
-* `composer require symfony/dotenv:^4.2 --dev`
-* Follow [Symfony dotenv update guide](https://symfony.com/doc/current/configuration/dot-env-changes.html) to incorporate required changes in `.env` files structure. Remember - they should be done on `tests/Application/` level! Optionally, you can take a look at [corresponding PR](https://github.com/Sylius/PluginSkeleton/pull/156/) introducing these changes in **PluginSkeleton** (this PR also includes changes with Behat - see below)
-
-Don't forget to clear the cache (`tests/Application/bin/console cache:clear`) to be 100% everything is loaded properly.
-
-### Test application kernel
-
-The kernel of the test application needs to be replaced with this [file](https://github.com/Sylius/PluginSkeleton/blob/1.4/tests/Application/Kernel.php).
-The location of the kernel is: `tests/Application/Kernel.php` (replace the content with the content of the file above).
-The container cleanup method is removed in the new version and keeping it will cause problems with for example the `TagAwareAdapter` which will call `commit()` on its pool from its destructor. If its pool is `TraceableAdapter` with pool `ArrayAdapter`, then the pool property of `TraceableAdapter` will be nullified before the destructor is executed and cause an error.
-
----
-
-### Behat
-
-If you're using Behat and want to be up-to-date with our configuration
-
-* Update required extensions with `composer require friends-of-behat/symfony-extension:^2.0 friends-of-behat/page-object-extension:^0.3 --dev`
-* Remove extensions that are not needed yet with `composer remove friends-of-behat/context-service-extension friends-of-behat/cross-container-extension friends-of-behat/service-container-extension --dev`
-* Update your `behat.yml` - look at the diff [here](https://github.com/Sylius/Sylius-Standard/pull/322/files#diff-7bde54db60a6e933518d8b61b929edce)
-* Add `SymfonyExtensionBundle` to your `tests/Application/config/bundles.php`:
- ```php
- return [
- //...
- FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class => ['test' => true, 'test_cached' => true],
- ];
- ```
-* If you use our Travis CI configuration, follow [these changes](https://github.com/Sylius/PluginSkeleton/pull/156/files#diff-354f30a63fb0907d4ad57269548329e3) introduced in `.travis.yml` file
-* Create `tests/Application/config/services_test.yaml` file with the following code and add these your own Behat services as well:
- ```yaml
- imports:
- - { resource: "../../../vendor/sylius/sylius/src/Sylius/Behat/Resources/config/services.xml" }
- ```
-* Remove all `__symfony__` prefixes in your Behat services
-* Remove all `` tags from your Behat services
-* Make your Behat services public by default with ``
-* Change `contexts_services ` in your suite definitions to `contexts`
-* Take a look at [SymfonyExtension UPGRADE guide](https://github.com/FriendsOfBehat/SymfonyExtension/blob/master/UPGRADE-2.0.md) if you have any more problems
-
-### Phpstan
-
-* Fix the container XML path parameter in the `phpstan.neon` file as done [here](https://github.com/Sylius/PluginSkeleton/commit/37fa614dbbcf8eb31b89eaf202b4bd4d89a5c7b3)
-
-# UPGRADE FROM `v1.2.X` TO `v1.4.0`
-
-Firstly, check out the [PluginSkeleton 1.3 upgrade guide](https://github.com/Sylius/PluginSkeleton/blob/1.4/UPGRADE-1.3.md) to update Sylius version step by step.
-To upgrade to Sylius 1.4 follow instructions from [the previous section](https://github.com/Sylius/PluginSkeleton/blob/1.4/UPGRADE-1.4.md#upgrade-from-v13x-to-v140) with following changes:
-
-### Doctrine migrations
-
-* Change namespaces of copied migrations to `Sylius\Migrations`
-
-### Dotenv
-
-* These changes are not required, but can be done as well, if you've changed application directory structure in `1.2.x` to `1.3` update
-
-### Behat
-
-* Add `\FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle()` to your bundles lists in `tests/Application/AppKernel.php` (preferably only in `test` environment)
-* Import Sylius Behat services in `tests/Application/config/config_test.yml` and your own Behat services as well:
- ```yaml
- imports:
- - { resource: "../../../../vendor/sylius/sylius/src/Sylius/Behat/Resources/config/services.xml" }
- ```
-* Specify test application's kernel path in `behat.yml`:
- ```yaml
- FriendsOfBehat\SymfonyExtension:
- kernel:
- class: AppKernel
- path: tests/Application/app/AppKernel.php
- ```
-
-
-# UPGRADE FROM `v1.2.X` TO `v1.3.0`
-
-## Application
-
-* Run `composer require sylius/sylius:~1.3.0 --no-update`
-
-* Add the following code in your `behat.yml(.dist)` file:
-
- ```yaml
- default:
- extensions:
- FriendsOfBehat\SymfonyExtension:
- env_file: ~
- ```
-
-* Incorporate changes from the following files into plugin's test application:
-
- * [`tests/Application/package.json`](https://github.com/Sylius/PluginSkeleton/blob/1.3/tests/Application/package.json) ([see diff](https://github.com/Sylius/PluginSkeleton/pull/134/files#diff-726e1353c14df7d91379c0dea6b30eef))
- * [`tests/Application/.babelrc`](https://github.com/Sylius/PluginSkeleton/blob/1.3/tests/Application/.babelrc) ([see diff](https://github.com/Sylius/PluginSkeleton/pull/134/files#diff-a2527d9d8ad55460b2272274762c9386))
- * [`tests/Application/.eslintrc.js`](https://github.com/Sylius/PluginSkeleton/blob/1.3/tests/Application/.eslintrc.js) ([see diff](https://github.com/Sylius/PluginSkeleton/pull/134/files#diff-396c8c412b119deaa7dd84ae28ae04ca))
-
-* Update PHP and JS dependencies by running `composer update` and `(cd tests/Application && yarn upgrade)`
-
-* Clear cache by running `(cd tests/Application && bin/console cache:clear)`
-
-* Install assets by `(cd tests/Application && bin/console assets:install web)` and `(cd tests/Application && yarn build)`
-
-* optionally, remove the build for PHP 7.1. in `.travis.yml`
diff --git a/src/Resources/assets/admin/automaticBlacklistingConfiguration.js b/assets/admin/automaticBlacklistingConfiguration.js
similarity index 100%
rename from src/Resources/assets/admin/automaticBlacklistingConfiguration.js
rename to assets/admin/automaticBlacklistingConfiguration.js
diff --git a/src/Resources/assets/admin/entry.js b/assets/admin/entry.js
similarity index 100%
rename from src/Resources/assets/admin/entry.js
rename to assets/admin/entry.js
diff --git a/src/Resources/assets/shop/entry.js b/assets/shop/entry.js
similarity index 100%
rename from src/Resources/assets/shop/entry.js
rename to assets/shop/entry.js
diff --git a/composer.json b/composer.json
index ccb86873..2ee617ef 100644
--- a/composer.json
+++ b/composer.json
@@ -5,41 +5,46 @@
"description": "Blacklist plugin for Sylius.",
"license": "MIT",
"require": {
- "php": "^8.0",
- "sylius/sylius": "^1.12",
- "doctrine/annotations": "^2.0.0"
+ "php": "^8.2",
+ "sylius/sylius": "~2.0.0",
+ "dompdf/dompdf": "^2.0",
+ "symfony/webpack-encore-bundle": "^2.1",
+ "symfony/workflow": "^7.2"
},
"require-dev": {
- "behat/behat": "^3.7.0",
- "behat/mink": "^1.8",
- "behat/mink-selenium2-driver": "~1.6.0",
+ "behat/behat": "^3.14",
+ "behat/mink-selenium2-driver": "1.6",
"bitbag/coding-standard": "^3.0.0",
- "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",
- "friends-of-behat/mink-extension": "^2.4",
+ "dmore/behat-chrome-extension": "^1.4",
+ "friends-of-behat/mink": "^1.11",
+ "friends-of-behat/mink-browserkit-driver": "^1.6",
+ "friends-of-behat/mink-debug-extension": "^2.1",
+ "friends-of-behat/mink-extension": "^2.7",
"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",
- "lchrusciel/api-test-case": "^4.1||^5.0",
+ "friends-of-behat/suite-settings-extension": "^1.1",
+ "friends-of-behat/symfony-extension": "^2.6",
+ "friends-of-behat/variadic-extension": "^1.6",
+ "gedmo/doctrine-extensions": "^3.9",
+ "lchrusciel/api-test-case": "^4.1 || ^5.0",
+ "league/flysystem-bundle": "^3.3",
+ "nelmio/alice": "^3.10",
+ "nyholm/psr7": "^1.8",
"phpspec/phpspec": "^7.0",
- "phpstan/extension-installer": "^1.0",
- "phpstan/phpstan": "^1.4",
- "phpstan/phpstan-doctrine": "^1.0",
- "phpstan/phpstan-strict-rules": "^1.0",
- "phpstan/phpstan-webmozart-assert": "^1.0",
"phpunit/phpunit": "^9.5",
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
- "symfony/browser-kit": "^5.4 || 6.4",
- "symfony/debug-bundle": "^5.4 || ^6.4",
- "symfony/dotenv": "^5.4 || ^6.4",
- "symfony/intl": "^5.4 || ^6.4",
- "symfony/web-profiler-bundle": "^5.4 || ^6.4",
- "vimeo/psalm": "^4.7 || ^5.0",
- "symfony/webpack-encore-bundle": "^1.17"
+ "robertfausk/behat-panther-extension": "^1.1",
+ "sylius-labs/coding-standard": "^4.4",
+ "sylius-labs/suite-tags-extension": "~0.2",
+ "sylius/mailer-bundle": "^1.8 || ^2.0@beta",
+ "sylius/sylius-rector": "^2.0",
+ "symfony/browser-kit": "^6.4 || ^7.1",
+ "symfony/debug-bundle": "^6.4 || ^7.1",
+ "symfony/dependency-injection": "^6.4 || ^7.1",
+ "symfony/dotenv": "^6.4 || ^7.1",
+ "symfony/http-client": "^6.4 || ^7.1",
+ "symfony/intl": "^6.4 || ^7.1",
+ "symfony/web-profiler-bundle": "^6.4 || ^7.1",
+ "symfony/profiler-pack": "^1.0"
},
"autoload": {
"psr-4": {
@@ -56,7 +61,8 @@
"symfony/thanks": true,
"composer/package-versions-deprecated": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
- "phpstan/extension-installer": true
+ "phpstan/extension-installer": true,
+ "php-http/discovery": true
}
},
"scripts": {
diff --git a/src/Resources/config/config.yaml b/config/config.yaml
similarity index 59%
rename from src/Resources/config/config.yaml
rename to config/config.yaml
index a655a62a..2ce2447f 100644
--- a/src/Resources/config/config.yaml
+++ b/config/config.yaml
@@ -1,5 +1,6 @@
imports:
+ - { resource: "twig_hooks/**/*.yaml" }
- { resource: "resources.yaml" }
- { resource: "services.xml" }
- { resource: "grids.yaml" }
- - { resource: "state_machine.yaml" }
+ - { resource: "workflow.yaml" }
diff --git a/src/Resources/config/doctrine/FraudPrevention.AutomaticBlacklistingConfiguration.orm.xml b/config/doctrine/FraudPrevention.AutomaticBlacklistingConfiguration.orm.xml
similarity index 100%
rename from src/Resources/config/doctrine/FraudPrevention.AutomaticBlacklistingConfiguration.orm.xml
rename to config/doctrine/FraudPrevention.AutomaticBlacklistingConfiguration.orm.xml
diff --git a/src/Resources/config/doctrine/FraudPrevention.AutomaticBlacklistingRule.orm.xml b/config/doctrine/FraudPrevention.AutomaticBlacklistingRule.orm.xml
similarity index 100%
rename from src/Resources/config/doctrine/FraudPrevention.AutomaticBlacklistingRule.orm.xml
rename to config/doctrine/FraudPrevention.AutomaticBlacklistingRule.orm.xml
diff --git a/src/Resources/config/doctrine/FraudPrevention.BlacklistingRule.orm.xml b/config/doctrine/FraudPrevention.BlacklistingRule.orm.xml
similarity index 100%
rename from src/Resources/config/doctrine/FraudPrevention.BlacklistingRule.orm.xml
rename to config/doctrine/FraudPrevention.BlacklistingRule.orm.xml
diff --git a/src/Resources/config/doctrine/FraudPrevention.FraudSuspicion.orm.xml b/config/doctrine/FraudPrevention.FraudSuspicion.orm.xml
similarity index 100%
rename from src/Resources/config/doctrine/FraudPrevention.FraudSuspicion.orm.xml
rename to config/doctrine/FraudPrevention.FraudSuspicion.orm.xml
diff --git a/src/Resources/config/grids.yaml b/config/grids.yaml
similarity index 100%
rename from src/Resources/config/grids.yaml
rename to config/grids.yaml
diff --git a/src/Resources/config/grids/admin/automatic_blacklisting_configuration.yaml b/config/grids/admin/automatic_blacklisting_configuration.yaml
similarity index 91%
rename from src/Resources/config/grids/admin/automatic_blacklisting_configuration.yaml
rename to config/grids/admin/automatic_blacklisting_configuration.yaml
index 6001e74e..6c0d4189 100644
--- a/src/Resources/config/grids/admin/automatic_blacklisting_configuration.yaml
+++ b/config/grids/admin/automatic_blacklisting_configuration.yaml
@@ -19,13 +19,13 @@ sylius_grid:
label: sylius.ui.enabled
sortable: ~
options:
- template: "@SyliusUi/Grid/Field/enabled.html.twig"
+ template: "@SyliusUi/grid/field/enabled.html.twig"
addFraudSuspicion:
type: twig
label: bitbag_sylius_blacklist_plugin.ui.add_fraud_suspicion_row_after_exceed_limit
sortable: ~
options:
- template: "@SyliusUi/Grid/Field/yesNo.html.twig"
+ template: "@SyliusUi/grid/field/yes_no.html.twig"
filters:
name:
type: string
@@ -50,4 +50,4 @@ sylius_grid:
type: delete
main:
create:
- type: create
\ No newline at end of file
+ type: create
diff --git a/src/Resources/config/grids/admin/blacklisting_rule.yaml b/config/grids/admin/blacklisting_rule.yaml
similarity index 93%
rename from src/Resources/config/grids/admin/blacklisting_rule.yaml
rename to config/grids/admin/blacklisting_rule.yaml
index 40258461..c9a3d057 100644
--- a/src/Resources/config/grids/admin/blacklisting_rule.yaml
+++ b/config/grids/admin/blacklisting_rule.yaml
@@ -28,13 +28,13 @@ sylius_grid:
label: sylius.ui.enabled
sortable: ~
options:
- template: "@SyliusUi/Grid/Field/enabled.html.twig"
+ template: "@SyliusUi/grid/field/enabled.html.twig"
onlyForGuests:
type: twig
label: bitbag_sylius_blacklist_plugin.form.blacklisting_rule.only_for_guests
sortable: ~
options:
- template: "@SyliusUi/Grid/Field/yesNo.html.twig"
+ template: "@SyliusUi/grid/field/yes_no.html.twig"
filters:
name:
type: string
@@ -62,4 +62,4 @@ sylius_grid:
type: delete
main:
create:
- type: create
\ No newline at end of file
+ type: create
diff --git a/src/Resources/config/grids/admin/fraud_suspicion.yaml b/config/grids/admin/fraud_suspicion.yaml
similarity index 100%
rename from src/Resources/config/grids/admin/fraud_suspicion.yaml
rename to config/grids/admin/fraud_suspicion.yaml
diff --git a/src/Resources/config/resources.yaml b/config/resources.yaml
similarity index 100%
rename from src/Resources/config/resources.yaml
rename to config/resources.yaml
diff --git a/src/Resources/config/resources/automatic_blacklisting_configuration.yaml b/config/resources/automatic_blacklisting_configuration.yaml
similarity index 100%
rename from src/Resources/config/resources/automatic_blacklisting_configuration.yaml
rename to config/resources/automatic_blacklisting_configuration.yaml
diff --git a/src/Resources/config/resources/automatic_blacklisting_rule.yaml b/config/resources/automatic_blacklisting_rule.yaml
similarity index 100%
rename from src/Resources/config/resources/automatic_blacklisting_rule.yaml
rename to config/resources/automatic_blacklisting_rule.yaml
diff --git a/src/Resources/config/resources/blacklisting_rule.yaml b/config/resources/blacklisting_rule.yaml
similarity index 100%
rename from src/Resources/config/resources/blacklisting_rule.yaml
rename to config/resources/blacklisting_rule.yaml
diff --git a/src/Resources/config/resources/fraud_suspicion.yaml b/config/resources/fraud_suspicion.yaml
similarity index 100%
rename from src/Resources/config/resources/fraud_suspicion.yaml
rename to config/resources/fraud_suspicion.yaml
diff --git a/config/routing.yaml b/config/routing.yaml
new file mode 100644
index 00000000..a72d0dfd
--- /dev/null
+++ b/config/routing.yaml
@@ -0,0 +1,7 @@
+bitbag_sylius_blacklist_plugin_admin:
+ resource: "@BitBagSyliusBlacklistPlugin/config/routing/admin.yaml"
+ prefix: /admin
+
+bitbag_sylius_blacklist_plugin_shop:
+ resource: "@BitBagSyliusBlacklistPlugin/config/routing/shop.yaml"
+ prefix: /{_locale}
diff --git a/src/Resources/config/routing/admin.yaml b/config/routing/admin.yaml
similarity index 100%
rename from src/Resources/config/routing/admin.yaml
rename to config/routing/admin.yaml
diff --git a/src/Resources/config/routing/admin/automatic_blacklisting_configuration.yaml b/config/routing/admin/automatic_blacklisting_configuration.yaml
similarity index 81%
rename from src/Resources/config/routing/admin/automatic_blacklisting_configuration.yaml
rename to config/routing/admin/automatic_blacklisting_configuration.yaml
index fb70ef58..a9767fa6 100644
--- a/src/Resources/config/routing/admin/automatic_blacklisting_configuration.yaml
+++ b/config/routing/admin/automatic_blacklisting_configuration.yaml
@@ -2,10 +2,12 @@ bitbag_sylius_blacklist_plugin_admin_automatic_blacklisting_configuration:
resource: |
alias: bitbag_sylius_blacklist_plugin.automatic_blacklisting_configuration
section: admin
- templates: "@SyliusAdmin\\Crud"
+ templates: "@SyliusAdmin\\shared\\crud"
grid: bitbag_sylius_blacklist_plugin_automatic_blacklisting_configuration
except: ['show']
permission: true
+ form:
+ type: BitBag\SyliusBlacklistPlugin\Form\Type\AutomaticBlacklistingConfigurationType
vars:
all:
subheader: bitbag_sylius_blacklist_plugin.ui.configure_automatic_blacklisting_configurations
diff --git a/src/Resources/config/routing/admin/blacklisting_rule.yaml b/config/routing/admin/blacklisting_rule.yaml
similarity index 92%
rename from src/Resources/config/routing/admin/blacklisting_rule.yaml
rename to config/routing/admin/blacklisting_rule.yaml
index b6f5b040..1f12d59f 100644
--- a/src/Resources/config/routing/admin/blacklisting_rule.yaml
+++ b/config/routing/admin/blacklisting_rule.yaml
@@ -2,7 +2,7 @@ bitbag_sylius_blacklist_plugin_admin_blacklisting_rule:
resource: |
alias: bitbag_sylius_blacklist_plugin.blacklisting_rule
section: admin
- templates: "@SyliusAdmin\\Crud"
+ templates: "@SyliusAdmin\\shared\\crud"
grid: bitbag_sylius_blacklist_plugin_blacklisting_rule
except: ['show']
permission: true
diff --git a/src/Resources/config/routing/admin/fraud_suspicion.yaml b/config/routing/admin/fraud_suspicion.yaml
similarity index 90%
rename from src/Resources/config/routing/admin/fraud_suspicion.yaml
rename to config/routing/admin/fraud_suspicion.yaml
index 60b457e1..930bdad6 100644
--- a/src/Resources/config/routing/admin/fraud_suspicion.yaml
+++ b/config/routing/admin/fraud_suspicion.yaml
@@ -2,7 +2,7 @@ bitbag_sylius_blacklist_plugin_admin_fraud_suspicion:
resource: |
alias: bitbag_sylius_blacklist_plugin.fraud_suspicion
section: admin
- templates: "@SyliusAdmin\\Crud"
+ templates: "@SyliusAdmin\\shared\\crud"
grid: bitbag_sylius_blacklist_plugin_fraud_suspicion
permission: true
vars:
@@ -12,7 +12,7 @@ bitbag_sylius_blacklist_plugin_admin_fraud_suspicion:
icon: clipboard list
type: sylius.resource
-bitbag_sylius_blacklist_plugin_admin_fraud_suspicion_show:
+sylius_admin_fraud_suspicion_show:
path: fraud-suspicions/{id}
methods: [GET]
defaults:
@@ -34,8 +34,7 @@ bitbag_sylius_blacklist_plugin_admin_order_mark_suspicious:
parameters:
orderId: $orderId
section: admin
- template: "@SyliusAdmin/Crud/create.html.twig"
- form: BitBag\SyliusBlacklistPlugin\Form\Type\FraudSuspicionOrderType
+ template: "@SyliusAdmin/shared/crud/create.html.twig"
factory:
method: createForOrder
arguments:
diff --git a/src/Resources/config/routing/admin/order.yaml b/config/routing/admin/order.yaml
similarity index 100%
rename from src/Resources/config/routing/admin/order.yaml
rename to config/routing/admin/order.yaml
diff --git a/src/Resources/config/routing/shop.yaml b/config/routing/shop.yaml
similarity index 100%
rename from src/Resources/config/routing/shop.yaml
rename to config/routing/shop.yaml
diff --git a/src/Resources/config/services.xml b/config/services.xml
similarity index 100%
rename from src/Resources/config/services.xml
rename to config/services.xml
diff --git a/src/Resources/config/services/checker/address.xml b/config/services/checker/address.xml
similarity index 100%
rename from src/Resources/config/services/checker/address.xml
rename to config/services/checker/address.xml
diff --git a/src/Resources/config/services/checker/automatic_blacklisting_rule.xml b/config/services/checker/automatic_blacklisting_rule.xml
similarity index 100%
rename from src/Resources/config/services/checker/automatic_blacklisting_rule.xml
rename to config/services/checker/automatic_blacklisting_rule.xml
diff --git a/src/Resources/config/services/checker/blacklisting_rule.xml b/config/services/checker/blacklisting_rule.xml
similarity index 100%
rename from src/Resources/config/services/checker/blacklisting_rule.xml
rename to config/services/checker/blacklisting_rule.xml
diff --git a/src/Resources/config/services/checker/customer.xml b/config/services/checker/customer.xml
similarity index 100%
rename from src/Resources/config/services/checker/customer.xml
rename to config/services/checker/customer.xml
diff --git a/src/Resources/config/services/checker/fraud_suspicion.xml b/config/services/checker/fraud_suspicion.xml
similarity index 100%
rename from src/Resources/config/services/checker/fraud_suspicion.xml
rename to config/services/checker/fraud_suspicion.xml
diff --git a/src/Resources/config/services/checker/user.xml b/config/services/checker/user.xml
similarity index 100%
rename from src/Resources/config/services/checker/user.xml
rename to config/services/checker/user.xml
diff --git a/src/Resources/config/services/converter/fraud_suspicion.xml b/config/services/converter/fraud_suspicion.xml
similarity index 100%
rename from src/Resources/config/services/converter/fraud_suspicion.xml
rename to config/services/converter/fraud_suspicion.xml
diff --git a/src/Resources/config/services/event_listener/fraud_suspicion.xml b/config/services/event_listener/fraud_suspicion.xml
similarity index 100%
rename from src/Resources/config/services/event_listener/fraud_suspicion.xml
rename to config/services/event_listener/fraud_suspicion.xml
diff --git a/src/Resources/config/services/factory/fraud_suspicion.xml b/config/services/factory/fraud_suspicion.xml
similarity index 100%
rename from src/Resources/config/services/factory/fraud_suspicion.xml
rename to config/services/factory/fraud_suspicion.xml
diff --git a/src/Resources/config/services/form.xml b/config/services/form.xml
similarity index 90%
rename from src/Resources/config/services/form.xml
rename to config/services/form.xml
index 7e19afe6..88456016 100644
--- a/src/Resources/config/services/form.xml
+++ b/config/services/form.xml
@@ -39,16 +39,16 @@
+
%sylius.model.order.class%
%bitbag.sylius_blacklist_plugin.form.type.checkout_address.validation_groups%
-
+ %bitbag.sylius_blacklist_plugin.automatic_blacklisting_rules%
%bitbag_sylius_blacklist_plugin.model.automatic_blacklisting_configuration.class%
- %bitbag.sylius_blacklist_plugin.form.type.automatic_blacklisting_configuration.validation_groups%
%bitbag.sylius_blacklist_plugin.form.type.validation_groups%
@@ -69,5 +69,10 @@
%bitbag.sylius_blacklist_plugin.automatic_blacklisting_rules%
+
+ %sylius.model.customer.class%
+
+
+
diff --git a/src/Resources/config/services/form_extension.xml b/config/services/form_extension.xml
similarity index 100%
rename from src/Resources/config/services/form_extension.xml
rename to config/services/form_extension.xml
diff --git a/src/Resources/config/services/menu.xml b/config/services/menu.xml
similarity index 100%
rename from src/Resources/config/services/menu.xml
rename to config/services/menu.xml
diff --git a/src/Resources/config/services/processor/automatic_blacklisting_rule.xml b/config/services/processor/automatic_blacklisting_rule.xml
similarity index 100%
rename from src/Resources/config/services/processor/automatic_blacklisting_rule.xml
rename to config/services/processor/automatic_blacklisting_rule.xml
diff --git a/src/Resources/config/services/repository.xml b/config/services/repository.xml
similarity index 100%
rename from src/Resources/config/services/repository.xml
rename to config/services/repository.xml
diff --git a/src/Resources/config/services/resolver/address_type.xml b/config/services/resolver/address_type.xml
similarity index 100%
rename from src/Resources/config/services/resolver/address_type.xml
rename to config/services/resolver/address_type.xml
diff --git a/src/Resources/config/services/resolver/fraud_suspicion.xml b/config/services/resolver/fraud_suspicion.xml
similarity index 100%
rename from src/Resources/config/services/resolver/fraud_suspicion.xml
rename to config/services/resolver/fraud_suspicion.xml
diff --git a/src/Resources/config/services/state_resolver/customer.xml b/config/services/state_resolver/customer.xml
similarity index 74%
rename from src/Resources/config/services/state_resolver/customer.xml
rename to config/services/state_resolver/customer.xml
index 8a7ead4a..6579a728 100644
--- a/src/Resources/config/services/state_resolver/customer.xml
+++ b/config/services/state_resolver/customer.xml
@@ -7,8 +7,9 @@
>
-
-
+
+
+
diff --git a/config/services/twig/component.xml b/config/services/twig/component.xml
new file mode 100644
index 00000000..917700f3
--- /dev/null
+++ b/config/services/twig/component.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+ %bitbag_sylius_blacklist_plugin.model.automatic_blacklisting_configuration.class%
+ BitBag\SyliusBlacklistPlugin\Form\Type\AutomaticBlacklistingConfigurationType
+
+
+
+
+
+
+ %bitbag_sylius_blacklist_plugin.model.blacklisting_rule.class%
+ BitBag\SyliusBlacklistPlugin\Form\Type\BlacklistingRuleType
+
+
+
+
+
+
+ %bitbag_sylius_blacklist_plugin.model.fraud_suspicion.class%
+ BitBag\SyliusBlacklistPlugin\Form\Type\FraudSuspicionType
+
+
+
+
diff --git a/config/services/twig/extension.xml b/config/services/twig/extension.xml
new file mode 100644
index 00000000..dca5a147
--- /dev/null
+++ b/config/services/twig/extension.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+ %bitbag.sylius_blacklist_plugin.automatic_blacklisting_rules%
+
+
+
+
diff --git a/src/Resources/config/services/validator/blacklisting_rule.xml b/config/services/validator/blacklisting_rule.xml
similarity index 100%
rename from src/Resources/config/services/validator/blacklisting_rule.xml
rename to config/services/validator/blacklisting_rule.xml
diff --git a/src/Resources/config/services/validator/checkout.xml b/config/services/validator/checkout.xml
similarity index 100%
rename from src/Resources/config/services/validator/checkout.xml
rename to config/services/validator/checkout.xml
diff --git a/config/twig_hooks/automatic_blacklisting_configuration/create.yaml b/config/twig_hooks/automatic_blacklisting_configuration/create.yaml
new file mode 100644
index 00000000..abeab619
--- /dev/null
+++ b/config/twig_hooks/automatic_blacklisting_configuration/create.yaml
@@ -0,0 +1,11 @@
+sylius_twig_hooks:
+ hooks:
+ 'sylius_admin.automatic_blacklisting_configuration.create.content':
+ form:
+ component: 'sylius_admin:automatic_blacklisting_configuration:form'
+ props:
+ resource: '@=_context.resource'
+ form: '@=_context.form'
+ template: '@BitBagSyliusBlacklistPlugin/AutomaticBlacklistingConfiguration/Admin/form.html.twig'
+ configuration:
+ render_rest: false
diff --git a/config/twig_hooks/automatic_blacklisting_configuration/update.yaml b/config/twig_hooks/automatic_blacklisting_configuration/update.yaml
new file mode 100644
index 00000000..2e7f3790
--- /dev/null
+++ b/config/twig_hooks/automatic_blacklisting_configuration/update.yaml
@@ -0,0 +1,11 @@
+sylius_twig_hooks:
+ hooks:
+ 'sylius_admin.automatic_blacklisting_configuration.update.content':
+ form:
+ component: 'sylius_admin:automatic_blacklisting_configuration:form'
+ props:
+ resource: '@=_context.resource'
+ form: '@=_context.form'
+ template: '@BitBagSyliusBlacklistPlugin/AutomaticBlacklistingConfiguration/Admin/form.html.twig'
+ configuration:
+ method: 'PUT'
diff --git a/config/twig_hooks/blacklisting_rule/create.yaml b/config/twig_hooks/blacklisting_rule/create.yaml
new file mode 100644
index 00000000..faa533e1
--- /dev/null
+++ b/config/twig_hooks/blacklisting_rule/create.yaml
@@ -0,0 +1,11 @@
+sylius_twig_hooks:
+ hooks:
+ 'sylius_admin.blacklisting_rule.create.content':
+ form:
+ component: 'sylius_admin:blacklisting_rule:form'
+ props:
+ resource: '@=_context.resource'
+ form: '@=_context.form'
+ template: '@BitBagSyliusBlacklistPlugin/BlacklistingRule/Admin/form.html.twig'
+ configuration:
+ render_rest: false
diff --git a/config/twig_hooks/blacklisting_rule/update.yaml b/config/twig_hooks/blacklisting_rule/update.yaml
new file mode 100644
index 00000000..923c2ef6
--- /dev/null
+++ b/config/twig_hooks/blacklisting_rule/update.yaml
@@ -0,0 +1,11 @@
+sylius_twig_hooks:
+ hooks:
+ 'sylius_admin.blacklisting_rule.update.content':
+ form:
+ component: 'sylius_admin:blacklisting_rule:form'
+ props:
+ resource: '@=_context.resource'
+ form: '@=_context.form'
+ template: '@BitBagSyliusBlacklistPlugin/BlacklistingRule/Admin/form.html.twig'
+ configuration:
+ method: 'PUT'
diff --git a/config/twig_hooks/customer/create.yaml b/config/twig_hooks/customer/create.yaml
new file mode 100644
index 00000000..084e4afd
--- /dev/null
+++ b/config/twig_hooks/customer/create.yaml
@@ -0,0 +1,6 @@
+sylius_twig_hooks:
+ hooks:
+ 'sylius_admin.customer.update.content.form.sections#right':
+ extra_information:
+ template: '@BitBagSyliusBlacklistPlugin/Customer/Form/Sections/extra_information.html.twig'
+ priority: 0
diff --git a/config/twig_hooks/customer/update.yaml b/config/twig_hooks/customer/update.yaml
new file mode 100644
index 00000000..084e4afd
--- /dev/null
+++ b/config/twig_hooks/customer/update.yaml
@@ -0,0 +1,6 @@
+sylius_twig_hooks:
+ hooks:
+ 'sylius_admin.customer.update.content.form.sections#right':
+ extra_information:
+ template: '@BitBagSyliusBlacklistPlugin/Customer/Form/Sections/extra_information.html.twig'
+ priority: 0
diff --git a/config/twig_hooks/fraud_suspicion/create.yaml b/config/twig_hooks/fraud_suspicion/create.yaml
new file mode 100644
index 00000000..3d229300
--- /dev/null
+++ b/config/twig_hooks/fraud_suspicion/create.yaml
@@ -0,0 +1,11 @@
+sylius_twig_hooks:
+ hooks:
+ 'sylius_admin.fraud_suspicion.create.content':
+ form:
+ component: 'sylius_admin:fraud_suspicion:form'
+ props:
+ resource: '@=_context.resource'
+ form: '@=_context.form'
+ template: '@BitBagSyliusBlacklistPlugin/FraudSuspicion/Admin/form.html.twig'
+ configuration:
+ render_rest: false
diff --git a/config/twig_hooks/fraud_suspicion/show.yaml b/config/twig_hooks/fraud_suspicion/show.yaml
new file mode 100644
index 00000000..a3c8362f
--- /dev/null
+++ b/config/twig_hooks/fraud_suspicion/show.yaml
@@ -0,0 +1,5 @@
+sylius_twig_hooks:
+ hooks:
+ 'sylius_admin.fraud_suspicion.show.content':
+ general:
+ template: '@BitBagSyliusBlacklistPlugin/FraudSuspicion/Admin/show.html.twig'
diff --git a/config/twig_hooks/fraud_suspicion/update.yaml b/config/twig_hooks/fraud_suspicion/update.yaml
new file mode 100644
index 00000000..fa80ad25
--- /dev/null
+++ b/config/twig_hooks/fraud_suspicion/update.yaml
@@ -0,0 +1,11 @@
+sylius_twig_hooks:
+ hooks:
+ 'sylius_admin.fraud_suspicion.update.content':
+ form:
+ component: 'sylius_admin:fraud_suspicion:form'
+ props:
+ resource: '@=_context.resource'
+ form: '@=_context.form'
+ template: '@BitBagSyliusBlacklistPlugin/FraudSuspicion/Admin/form.html.twig'
+ configuration:
+ method: 'PUT'
diff --git a/config/twig_hooks/order/show.yaml b/config/twig_hooks/order/show.yaml
new file mode 100644
index 00000000..d356ca7f
--- /dev/null
+++ b/config/twig_hooks/order/show.yaml
@@ -0,0 +1,9 @@
+sylius_twig_hooks:
+ hooks:
+ 'sylius_admin.order.show.content.header.title_block':
+ title:
+ template: '@SyliusAdmin/order/show/content/header/title_block/title.html.twig'
+ priority: 100
+ actions:
+ template: '@BitBagSyliusBlacklistPlugin/Order/Show/Content/Header/Title_block/actions.html.twig'
+ priority: 0
diff --git a/src/Resources/config/validation/AutomaticBlacklistingConfiguration.xml b/config/validation/AutomaticBlacklistingConfiguration.xml
similarity index 100%
rename from src/Resources/config/validation/AutomaticBlacklistingConfiguration.xml
rename to config/validation/AutomaticBlacklistingConfiguration.xml
diff --git a/src/Resources/config/validation/BlacklistingRule.xml b/config/validation/BlacklistingRule.xml
similarity index 100%
rename from src/Resources/config/validation/BlacklistingRule.xml
rename to config/validation/BlacklistingRule.xml
diff --git a/src/Resources/config/validation/FraudSuspicion.xml b/config/validation/FraudSuspicion.xml
similarity index 100%
rename from src/Resources/config/validation/FraudSuspicion.xml
rename to config/validation/FraudSuspicion.xml
diff --git a/src/Resources/config/validation/Order.xml b/config/validation/Order.xml
similarity index 78%
rename from src/Resources/config/validation/Order.xml
rename to config/validation/Order.xml
index 7c31b1ba..d4c8f594 100644
--- a/src/Resources/config/validation/Order.xml
+++ b/config/validation/Order.xml
@@ -4,7 +4,10 @@
-
+
-
\ No newline at end of file
+
diff --git a/config/workflow.yaml b/config/workflow.yaml
new file mode 100644
index 00000000..abe3cf61
--- /dev/null
+++ b/config/workflow.yaml
@@ -0,0 +1,2 @@
+imports:
+ - { resource: "workflow/**" }
diff --git a/config/workflow/customer.yaml b/config/workflow/customer.yaml
new file mode 100644
index 00000000..b33bed50
--- /dev/null
+++ b/config/workflow/customer.yaml
@@ -0,0 +1,33 @@
+framework:
+ workflows:
+ !php/const BitBag\SyliusBlacklistPlugin\Transitions\CustomerTransitions::GRAPH:
+ type: state_machine
+ marking_store:
+ property: fraudStatus
+ type: method
+ supports:
+ - BitBag\SyliusBlacklistPlugin\Entity\Customer\FraudStatusInterface
+ initial_marking:
+ !php/const BitBag\SyliusBlacklistPlugin\Entity\Customer\FraudStatusInterface::FRAUD_STATUS_NEUTRAL
+ places:
+ - !php/const BitBag\SyliusBlacklistPlugin\Entity\Customer\FraudStatusInterface::FRAUD_STATUS_NEUTRAL
+ - !php/const BitBag\SyliusBlacklistPlugin\Entity\Customer\FraudStatusInterface::FRAUD_STATUS_BLACKLISTED
+ - !php/const BitBag\SyliusBlacklistPlugin\Entity\Customer\FraudStatusInterface::FRAUD_STATUS_WHITELISTED
+ transitions:
+ !php/const BitBag\SyliusBlacklistPlugin\Transitions\CustomerTransitions::TRANSITION_NEUTRALIZING_PROCESS:
+ from:
+ - !php/const BitBag\SyliusBlacklistPlugin\Entity\Customer\FraudStatusInterface::FRAUD_STATUS_BLACKLISTED
+ to:
+ - !php/const BitBag\SyliusBlacklistPlugin\Entity\Customer\FraudStatusInterface::FRAUD_STATUS_NEUTRAL
+
+ !php/const BitBag\SyliusBlacklistPlugin\Transitions\CustomerTransitions::TRANSITION_BLACKLISTING_PROCESS:
+ from:
+ - !php/const BitBag\SyliusBlacklistPlugin\Entity\Customer\FraudStatusInterface::FRAUD_STATUS_NEUTRAL
+ to:
+ - !php/const BitBag\SyliusBlacklistPlugin\Entity\Customer\FraudStatusInterface::FRAUD_STATUS_BLACKLISTED
+
+ !php/const BitBag\SyliusBlacklistPlugin\Transitions\CustomerTransitions::TRANSITION_WHITELISTING_PROCESS:
+ from:
+ - !php/const BitBag\SyliusBlacklistPlugin\Entity\Customer\FraudStatusInterface::FRAUD_STATUS_NEUTRAL
+ to:
+ - !php/const BitBag\SyliusBlacklistPlugin\Entity\Customer\FraudStatusInterface::FRAUD_STATUS_WHITELISTED
diff --git a/doc/installation.md b/doc/installation.md
index 1b3b35dd..936705b8 100644
--- a/doc/installation.md
+++ b/doc/installation.md
@@ -23,12 +23,12 @@ ADDITIONAL
## Requirements:
We work on stable, supported and up-to-date versions of packages. We recommend you to do the same.
-| Package | Version |
-|---------------|-----------------|
-| PHP | \>8.0 |
-| sylius/sylius | 1.12.x - 1.13.x |
-| MySQL | \>= 5.7 |
-| NodeJS | \>= 18.x |
+| Package | Version |
+|---------------|----------|
+| PHP | \>=8.2 |
+| sylius/sylius | 2.0.x |
+| MySQL | \>= 5.7 |
+| NodeJS | \>= 18.x |
## Composer:
```bash
@@ -54,7 +54,7 @@ Import required config in your `config/packages/_sylius.yaml` file:
imports:
...
- - { resource: "@BitBagSyliusBlacklistPlugin/Resources/config/config.yaml" }
+ - { resource: "@BitBagSyliusBlacklistPlugin/config/config.yaml" }
```
Add routing to your `config/routes.yaml` file:
@@ -62,7 +62,7 @@ Add routing to your `config/routes.yaml` file:
# config/routes.yaml
bitbag_sylius_blacklist_plugin:
- resource: "@BitBagSyliusBlacklistPlugin/Resources/config/routing.yaml"
+ resource: "@BitBagSyliusBlacklistPlugin/config/routing.yaml"
```
Override Customer grid in `config/packages/_sylius_grid.yml` file:
@@ -101,7 +101,6 @@ twig:
strict_variables: '%kernel.debug%'
form_themes:
- '@BitBagSyliusBlacklistPlugin/Form/theme.html.twig'
- - '@SyliusUi/Form/theme.html.twig'
services:
_defaults:
public: false
@@ -174,26 +173,6 @@ bin/console cache:clear
```
**Note:** If you are running it on production, add the `-e prod` flag to this command.
-## Templates
-
-**AdminBundle** (`templates/bundles/SyliusAdminBundle`):
-
-Override Customer form template (`@SyliusAdminBundle\Customer\_form.html.twig`
-or `@SyliusAdminBundle/Customer/Form/_firstColumn.html.twig`) by adding lines below:
-
-```php
-
-
- {{ form_row(form.fraudStatus) }}
-
-```
-
-or copy from the path:
-
-```
-vendor/bitbag/blacklist-plugin/tests/Application/templates/bundles/SyliusAdminBundle/Customer/_form.html.twig
-```
-
## Tests
To run the tests, execute the commands:
```bash
diff --git a/doc/installation/xml-mapping.md b/doc/installation/xml-mapping.md
index 38cf6cad..506392cb 100644
--- a/doc/installation/xml-mapping.md
+++ b/doc/installation/xml-mapping.md
@@ -14,7 +14,7 @@ doctrine:
App:
...
type: xml
- dir: '%kernel.project_dir%/src/Resources/config/doctrine'
+ dir: '%kernel.project_dir%/config/doctrine'
```
Extend entities with parameters and methods using attributes and traits:
@@ -38,11 +38,11 @@ class Customer extends BaseCustomer implements CustomerInterface
}
```
-Define new Entity mapping inside `src/Resources/config/doctrine` directory.
+Define new Entity mapping inside `config/doctrine` directory.
- `Customer` entity:
-`src/Resources/config/doctrine/Customer.orm.xml`
+`config/doctrine/Customer.orm.xml`
```xml
diff --git a/features/admin/adding_automatic_blacklisting_configuration.feature b/features/admin/adding_automatic_blacklisting_configuration.feature
index 1f5a5a96..c79d9fe8 100644
--- a/features/admin/adding_automatic_blacklisting_configuration.feature
+++ b/features/admin/adding_automatic_blacklisting_configuration.feature
@@ -51,8 +51,9 @@ Feature: Adding a new automatic blacklisting configuration
When I go to the create automatic blacklisting configuration page
And I name it "Fourth configuration"
And I select "United States" as channels
+ And I select "United States" as channels
And I enable it
And I add the "Max number of orders" rule configured with count "5" and "Per day" as date modifier
And I want to add fraud suspicion row after exceeding limit
And I add it
- Then I should be notified that I need to add settings to fraud suspicion section
\ No newline at end of file
+ Then I should be notified that I need to add settings to fraud suspicion section
diff --git a/features/shop/blocking_user_on_checkout_by_automatic_blacklisting_rule.feature b/features/shop/blocking_user_on_checkout_by_automatic_blacklisting_rule.feature
index 3364ebf4..8893f26c 100644
--- a/features/shop/blocking_user_on_checkout_by_automatic_blacklisting_rule.feature
+++ b/features/shop/blocking_user_on_checkout_by_automatic_blacklisting_rule.feature
@@ -17,7 +17,7 @@ Feature: Blocking users on checkout
And the customer bought a single "PHP T-Shirt"
And the customer chose "Free" shipping method to "United States" with "Cash on Delivery" payment
- @ui
+ @ui @javascript
Scenario: Successfully complete checkout addressing step
Given I have product "PHP Pullover" in the cart
And there is a automatic blacklisting configuration "First configuration" with rule "orders" configured with count "2" and date modifier "1 day"
@@ -26,7 +26,7 @@ Feature: Blocking users on checkout
And I complete the addressing step
Then I should be on the checkout shipping step
- @ui
+ @ui @javascript
Scenario: Blocking users on checkout by automatic blacklisting rules
Given I have product "PHP Blouse" in the cart
And there is a automatic blacklisting configuration "First configuration" with rule "orders" configured with count "1" and date modifier "1 day"
@@ -34,4 +34,4 @@ Feature: Blocking users on checkout
And I specify the billing address as "Ankh Morpork", "Frost Alley", "90210", "United States" for "Jon Snow"
And I complete the addressing step
Then I should be notified that something went wrong
- And I should be at the checkout addressing step
\ No newline at end of file
+ And I should be at the checkout addressing step
diff --git a/features/shop/blocking_user_on_checkout_by_manual_blacklisting_rule.feature b/features/shop/blocking_user_on_checkout_by_manual_blacklisting_rule.feature
index 7a9281bf..1f874b17 100644
--- a/features/shop/blocking_user_on_checkout_by_manual_blacklisting_rule.feature
+++ b/features/shop/blocking_user_on_checkout_by_manual_blacklisting_rule.feature
@@ -21,7 +21,7 @@ Feature: Blocking users on checkout
And the customer chose "Free" shipping method to "United States" with "Cash on Delivery" payment
And the order "#00000022" is marked as suspicious by fake "billing" address
- @ui
+ @ui @javascript
Scenario: Successfully complete checkout addressing step
Given I have product "PHP Pullover" in the cart
And there is a blacklisting rule with "Country" name and "3" permitted strikes and "country" as a rule attributes
@@ -30,7 +30,7 @@ Feature: Blocking users on checkout
And I complete the addressing step
Then I should be on the checkout shipping step
- @ui
+ @ui @javascript
Scenario: Successfully complete checkout by users for who manual blacklisting rule is not eligible
Given the customer belongs to group "Wholesale"
And I have product "PHP Pullover" in the cart
@@ -41,7 +41,7 @@ Feature: Blocking users on checkout
And I complete the addressing step
Then I should be on the checkout shipping step
- @ui
+ @ui @javascript
Scenario: Successfully complete checkout by users for who manual blacklisting rule is not eligible
Given I have product "PHP Pullover" in the cart
And there is a blacklisting rule with "Country" name and "1" permitted strikes and "country" as a rule attributes
@@ -51,7 +51,7 @@ Feature: Blocking users on checkout
And I complete the addressing step
Then I should be on the checkout shipping step
- @ui
+ @ui @javascript
Scenario: Blocking users on checkout by manual blacklisting rules
Given I have product "PHP Blouse" in the cart
And there is a blacklisting rule with "Country" name and "1" permitted strikes and "country" as a rule attributes
@@ -59,4 +59,4 @@ Feature: Blocking users on checkout
And I specify the billing address as "Francis Underwood", "Groove Street", "91920", "United States" for "Francis Underwood"
And I complete the addressing step
Then I should be notified that something went wrong
- And I should be at the checkout addressing step
\ No newline at end of file
+ And I should be at the checkout addressing step
diff --git a/spec/StateResolver/CustomerStateResolverSpec.php b/spec/StateResolver/CustomerStateResolverSpec.php
index c1c5febb..56bf844d 100644
--- a/spec/StateResolver/CustomerStateResolverSpec.php
+++ b/spec/StateResolver/CustomerStateResolverSpec.php
@@ -5,23 +5,22 @@
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
*/
+declare(strict_types=1);
namespace spec\BitBag\SyliusBlacklistPlugin\StateResolver;
use BitBag\SyliusBlacklistPlugin\StateResolver\CustomerStateResolver;
use BitBag\SyliusBlacklistPlugin\StateResolver\CustomerStateResolverInterface;
-use BitBag\SyliusBlacklistPlugin\Transitions\CustomerTransitions;
use Doctrine\Persistence\ObjectManager;
use PhpSpec\ObjectBehavior;
-use SM\Factory\FactoryInterface;
-use SM\StateMachine\StateMachineInterface;
-use Tests\BitBag\SyliusBlacklistPlugin\Entity\CustomerInterface;
+use Sylius\Component\Customer\Model\CustomerInterface;
+use Symfony\Component\Workflow\WorkflowInterface;
final class CustomerStateResolverSpec extends ObjectBehavior
{
- function let(FactoryInterface $stateMachineFactory, ObjectManager $customerManager): void
+ function let(WorkflowInterface $workflow, ObjectManager $customerManager): void
{
- $this->beConstructedWith($stateMachineFactory, $customerManager);
+ $this->beConstructedWith($workflow, $customerManager);
}
function it_is_initializable(): void
@@ -29,22 +28,34 @@ function it_is_initializable(): void
$this->shouldHaveType(CustomerStateResolver::class);
}
- function it_implements_automatic_blacklisting_rule_checker_interface(): void
+ function it_implements_customer_state_resolver_interface(): void
{
- $this->shouldHaveType(CustomerStateResolverInterface::class);
+ $this->shouldImplement(CustomerStateResolverInterface::class);
}
- function it_changes_fraud_status_of_customer(CustomerInterface $customer, FactoryInterface $stateMachineFactory, StateMachineInterface $stateMachine, ObjectManager $customerManager): void
- {
- $stateMachineFactory->get($customer, CustomerTransitions::GRAPH)->willReturn($stateMachine);
- $stateMachine->can(CustomerTransitions::TRANSITION_BLACKLISTING_PROCESS)->willReturn(true);
-
- $stateMachineFactory->get($customer, CustomerTransitions::GRAPH)->shouldBeCalled();
- $stateMachine->can(CustomerTransitions::TRANSITION_BLACKLISTING_PROCESS)->shouldBeCalled();
- $stateMachine->apply(CustomerTransitions::TRANSITION_BLACKLISTING_PROCESS)->shouldBeCalled();
+ function it_changes_state_on_blacklisted(
+ WorkflowInterface $workflow,
+ ObjectManager $customerManager,
+ CustomerInterface $customer
+ ): void {
+ $workflow->can($customer, 'blacklisting')->willReturn(true);
+ $workflow->apply($customer, 'blacklisting')->shouldBeCalled();
$customerManager->persist($customer)->shouldBeCalled();
$customerManager->flush()->shouldBeCalled();
$this->changeStateOnBlacklisted($customer);
}
+
+ function it_does_not_change_state_if_cannot_apply_blacklisting(
+ WorkflowInterface $workflow,
+ ObjectManager $customerManager,
+ CustomerInterface $customer
+ ): void {
+ $workflow->can($customer, 'blacklisting')->willReturn(false);
+ $workflow->apply($customer, 'blacklisting')->shouldNotBeCalled();
+ $customerManager->persist($customer)->shouldNotBeCalled();
+ $customerManager->flush()->shouldNotBeCalled();
+
+ $this->changeStateOnBlacklisted($customer);
+ }
}
diff --git a/src/BitBagSyliusBlacklistPlugin.php b/src/BitBagSyliusBlacklistPlugin.php
index 8d0efd47..47d9f417 100644
--- a/src/BitBagSyliusBlacklistPlugin.php
+++ b/src/BitBagSyliusBlacklistPlugin.php
@@ -28,4 +28,9 @@ public function build(ContainerBuilder $container): void
$container->addCompilerPass(new RegisterBlacklistingRuleCheckersPass());
$container->addCompilerPass(new RegisterAutomaticBlacklistingRuleCheckersPass());
}
+
+ public function getPath(): string
+ {
+ return \dirname(__DIR__);
+ }
}
diff --git a/src/Checker/FraudSuspicion/FraudSuspicionActionEligibilityChecker.php b/src/Checker/FraudSuspicion/FraudSuspicionActionEligibilityChecker.php
index 91177fb2..7dacb776 100644
--- a/src/Checker/FraudSuspicion/FraudSuspicionActionEligibilityChecker.php
+++ b/src/Checker/FraudSuspicion/FraudSuspicionActionEligibilityChecker.php
@@ -19,18 +19,10 @@
final class FraudSuspicionActionEligibilityChecker implements FraudSuspicionActionEligibilityCheckerInterface
{
- /** @var FraudSuspicionRepositoryInterface */
- private $fraudSuspicionRepository;
-
- /** @var CustomerStateResolverInterface */
- private $customerStateResolver;
-
public function __construct(
- FraudSuspicionRepositoryInterface $fraudSuspicionRepository,
- CustomerStateResolverInterface $customerStateResolver,
+ private readonly FraudSuspicionRepositoryInterface $fraudSuspicionRepository,
+ private readonly CustomerStateResolverInterface $customerStateResolver,
) {
- $this->fraudSuspicionRepository = $fraudSuspicionRepository;
- $this->customerStateResolver = $customerStateResolver;
}
public function canAddFraudSuspicion(
@@ -41,8 +33,7 @@ public function canAddFraudSuspicion(
return false;
}
- $date = (new \DateTime())->modify('- ' . $automaticBlacklistingConfiguration->getPermittedFraudSuspicionsTime());
-
+ $date = (new \DateTime())->modify('-' . $automaticBlacklistingConfiguration->getPermittedFraudSuspicionsTime());
$customer = $order->getCustomer();
$lastFraudSuspicionsOfCustomer = $this->fraudSuspicionRepository->countByCustomerAndCommentAndDate(
diff --git a/src/Checker/UserRoleChecker.php b/src/Checker/UserRoleChecker.php
index f61ccbbd..444abfd9 100644
--- a/src/Checker/UserRoleChecker.php
+++ b/src/Checker/UserRoleChecker.php
@@ -16,16 +16,14 @@
final class UserRoleChecker implements UserRoleCheckerInterface
{
- private TokenStorageInterface $tokenStorage;
-
- public function __construct(TokenStorageInterface $tokenStorage)
- {
- $this->tokenStorage = $tokenStorage;
+ public function __construct(
+ private readonly TokenStorageInterface $tokenStorage,
+ ) {
}
public function isAdmin(): bool
{
- $user = $this->tokenStorage->getToken()->getUser();
+ $user = $this->tokenStorage->getToken()?->getUser();
return $user instanceof AdminUserInterface;
}
diff --git a/src/Converter/FraudSuspicionCommonModelConverter.php b/src/Converter/FraudSuspicionCommonModelConverter.php
index 78b9aef0..6815e1e7 100644
--- a/src/Converter/FraudSuspicionCommonModelConverter.php
+++ b/src/Converter/FraudSuspicionCommonModelConverter.php
@@ -11,6 +11,7 @@
namespace BitBag\SyliusBlacklistPlugin\Converter;
+use BitBag\SyliusBlacklistPlugin\Dto\FraudSuspicionCommonDTO;
use BitBag\SyliusBlacklistPlugin\Entity\FraudPrevention\FraudSuspicion;
use BitBag\SyliusBlacklistPlugin\Entity\FraudPrevention\FraudSuspicionInterface;
use BitBag\SyliusBlacklistPlugin\Exception\WrongAddressTypeException;
@@ -21,67 +22,89 @@
class FraudSuspicionCommonModelConverter implements FraudSuspicionCommonModelConverterInterface
{
- /** @var FraudSuspicionCommonModelFactoryInterface */
- private $fraudSuspicionCommonModelFactory;
-
- public function __construct(FraudSuspicionCommonModelFactoryInterface $fraudSuspicionCommonModelFactory)
- {
- $this->fraudSuspicionCommonModelFactory = $fraudSuspicionCommonModelFactory;
+ public function __construct(
+ private readonly FraudSuspicionCommonModelFactoryInterface $fraudSuspicionCommonModelFactory,
+ ) {
}
public function convertFraudSuspicionObject(FraudSuspicionInterface $fraudSuspicion): FraudSuspicionCommonModelInterface
{
- $fraudSuspicionCommonModel = $this->fraudSuspicionCommonModelFactory->createNew();
-
- $fraudSuspicionCommonModel->setOrder($fraudSuspicion->getOrder());
- $fraudSuspicionCommonModel->setCustomer($fraudSuspicion->getCustomer());
- $fraudSuspicionCommonModel->setCompany($fraudSuspicion->getCompany());
- $fraudSuspicionCommonModel->setFirstName($fraudSuspicion->getFirstName());
- $fraudSuspicionCommonModel->setLastName($fraudSuspicion->getLastName());
- $fraudSuspicionCommonModel->setEmail($fraudSuspicion->getEmail());
- $fraudSuspicionCommonModel->setPhoneNumber($fraudSuspicion->getPhoneNumber());
- $fraudSuspicionCommonModel->setStreet($fraudSuspicion->getStreet());
- $fraudSuspicionCommonModel->setCity($fraudSuspicion->getCity());
- $fraudSuspicionCommonModel->setProvince($fraudSuspicion->getProvince());
- $fraudSuspicionCommonModel->setCountry($fraudSuspicion->getCountry());
- $fraudSuspicionCommonModel->setPostcode($fraudSuspicion->getPostcode());
- $fraudSuspicionCommonModel->setCustomerIp($fraudSuspicion->getCustomerIp());
+ $dto = new FraudSuspicionCommonDTO(
+ order: $fraudSuspicion->getOrder(),
+ customer: $fraudSuspicion->getCustomer(),
+ company: $fraudSuspicion->getCompany(),
+ firstName: $fraudSuspicion->getFirstName(),
+ lastName: $fraudSuspicion->getLastName(),
+ email: $fraudSuspicion->getEmail(),
+ phoneNumber: $fraudSuspicion->getPhoneNumber(),
+ street: $fraudSuspicion->getStreet(),
+ city: $fraudSuspicion->getCity(),
+ province: $fraudSuspicion->getProvince(),
+ country: $fraudSuspicion->getCountry(),
+ postcode: $fraudSuspicion->getPostcode(),
+ customerIp: $fraudSuspicion->getCustomerIp(),
+ );
- return $fraudSuspicionCommonModel;
+ return $this->populateFraudSuspicionCommonModel(
+ $this->fraudSuspicionCommonModelFactory->createNew(),
+ $dto,
+ );
}
public function convertOrderObject(OrderInterface $order, string $addressType): FraudSuspicionCommonModelInterface
{
$address = $this->getAddressFromOrder($order, $addressType);
- $fraudSuspicionCommonModel = $this->fraudSuspicionCommonModelFactory->createNew();
+ $dto = new FraudSuspicionCommonDTO(
+ order: $order,
+ customer: $order->getCustomer(),
+ company: $address?->getCompany() ?? '',
+ firstName: $address?->getFirstName() ?? '',
+ lastName: $address?->getLastName() ?? '',
+ email: $order->getCustomer()?->getEmail() ?? '',
+ phoneNumber: $address?->getPhoneNumber() ?? '',
+ street: $address?->getStreet() ?? '',
+ city: $address?->getCity() ?? '',
+ province: $address?->getProvinceName() ?? '',
+ country: $address?->getCountryCode() ?? '',
+ postcode: $address?->getPostcode() ?? '',
+ customerIp: $order->getCustomerIp() ?? ''
+ );
- $fraudSuspicionCommonModel->setOrder($order);
- $fraudSuspicionCommonModel->setCustomer($order->getCustomer());
- $fraudSuspicionCommonModel->setCompany($address->getCompany());
- $fraudSuspicionCommonModel->setFirstName($address->getFirstName());
- $fraudSuspicionCommonModel->setLastName($address->getLastName());
- $fraudSuspicionCommonModel->setEmail($order->getCustomer()->getEmail());
- $fraudSuspicionCommonModel->setPhoneNumber($address->getPhoneNumber());
- $fraudSuspicionCommonModel->setStreet($address->getStreet());
- $fraudSuspicionCommonModel->setCity($address->getCity());
- $fraudSuspicionCommonModel->setProvince($address->getProvinceName());
- $fraudSuspicionCommonModel->setCountry($address->getCountryCode());
- $fraudSuspicionCommonModel->setPostcode($address->getPostcode());
- $fraudSuspicionCommonModel->setCustomerIp($order->getCustomerIp());
- return $fraudSuspicionCommonModel;
+ return $this->populateFraudSuspicionCommonModel(
+ $this->fraudSuspicionCommonModelFactory->createNew(),
+ $dto,
+ );
}
- private function getAddressFromOrder(OrderInterface $order, string $addressType): AddressInterface
+ private function getAddressFromOrder(OrderInterface $order, string $addressType): ?AddressInterface
{
- switch ($addressType) {
- case FraudSuspicion::BILLING_ADDRESS_TYPE:
- return $order->getBillingAddress();
- case FraudSuspicion::SHIPPING_ADDRESS_TYPE:
- return $order->getShippingAddress();
- default:
- throw new WrongAddressTypeException('Wrong address type!');
- }
+ return match ($addressType) {
+ FraudSuspicion::BILLING_ADDRESS_TYPE => $order->getBillingAddress(),
+ FraudSuspicion::SHIPPING_ADDRESS_TYPE => $order->getShippingAddress(),
+ default => throw new WrongAddressTypeException('Wrong address type!'),
+ };
+ }
+
+ private function populateFraudSuspicionCommonModel(
+ FraudSuspicionCommonModelInterface $model,
+ FraudSuspicionCommonDTO $dto,
+ ): FraudSuspicionCommonModelInterface {
+ $model->setOrder($dto->order);
+ $model->setCustomer($dto->customer);
+ $model->setCompany($dto->company);
+ $model->setFirstName($dto->firstName);
+ $model->setLastName($dto->lastName);
+ $model->setEmail($dto->email);
+ $model->setPhoneNumber($dto->phoneNumber);
+ $model->setStreet($dto->street);
+ $model->setCity($dto->city);
+ $model->setProvince($dto->province);
+ $model->setCountry($dto->country);
+ $model->setPostcode($dto->postcode);
+ $model->setCustomerIp($dto->customerIp);
+
+ return $model;
}
}
diff --git a/src/DependencyInjection/BitBagSyliusBlacklistExtension.php b/src/DependencyInjection/BitBagSyliusBlacklistExtension.php
index 3af4a56a..51c492d9 100644
--- a/src/DependencyInjection/BitBagSyliusBlacklistExtension.php
+++ b/src/DependencyInjection/BitBagSyliusBlacklistExtension.php
@@ -22,7 +22,7 @@ final class BitBagSyliusBlacklistExtension extends Extension
public function load(array $config, ContainerBuilder $container): void
{
$config = $this->processConfiguration($this->getConfiguration([], $container), $config);
- $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
+ $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../../config'));
$loader->load('services.xml');
}
diff --git a/src/Dto/FraudSuspicionCommonDTO.php b/src/Dto/FraudSuspicionCommonDTO.php
new file mode 100644
index 00000000..aa702e6b
--- /dev/null
+++ b/src/Dto/FraudSuspicionCommonDTO.php
@@ -0,0 +1,35 @@
+suspiciousOrderResolver = $suspiciousOrderResolver;
- $this->customerStateResolver = $customerStateResolver;
- $this->fraudSuspicionCommonModelConverter = $fraudSuspicionCommonModelConverter;
}
public function prePersist(FraudSuspicionInterface $newFraudSuspicion, LifecycleEventArgs $event): void
diff --git a/src/Factory/FraudSuspicionFactory.php b/src/Factory/FraudSuspicionFactory.php
index 6544e159..27242420 100644
--- a/src/Factory/FraudSuspicionFactory.php
+++ b/src/Factory/FraudSuspicionFactory.php
@@ -17,33 +17,28 @@
final class FraudSuspicionFactory implements FraudSuspicionFactoryInterface
{
- private FactoryInterface $decoratedFactory;
-
- public function __construct(FactoryInterface $decoratedFactory)
- {
- $this->decoratedFactory = $decoratedFactory;
+ public function __construct(
+ private readonly FactoryInterface $decoratedFactory,
+ ) {
}
- /**
- * @return object
- */
- public function createNew()
+ public function createNew(): FraudSuspicionInterface
{
return $this->decoratedFactory->createNew();
}
public function createForOrder(OrderInterface $order): FraudSuspicionInterface
{
- /** @var FraudSuspicionInterface $fraudSuspicion */
$fraudSuspicion = $this->createNew();
$billingAddress = $order->getBillingAddress();
+ $customer = $order->getCustomer();
$fraudSuspicion->setOrder($order);
- $fraudSuspicion->setCustomer($order->getCustomer());
+ $fraudSuspicion->setCustomer($customer);
$fraudSuspicion->setCompany($billingAddress->getCompany());
$fraudSuspicion->setFirstName($billingAddress->getFirstName());
$fraudSuspicion->setLastName($billingAddress->getLastName());
- $fraudSuspicion->setEmail($order->getCustomer()->getEmail());
+ $fraudSuspicion->setEmail($customer?->getEmail());
$fraudSuspicion->setStreet($billingAddress->getStreet());
$fraudSuspicion->setCity($billingAddress->getCity());
$fraudSuspicion->setProvince($billingAddress->getProvinceName() ?? $billingAddress->getProvinceCode());
@@ -62,7 +57,7 @@ public function createForAutomaticBlacklistingConfiguration(OrderInterface $orde
$fraudSuspicion->setStatus(FraudSuspicionInterface::AUTO_GENERATED_STATUS);
if (null === $fraudSuspicion->getCustomerIp()) {
- $fraudSuspicion->setCustomerIp($_SERVER['REMOTE_ADDR']);
+ $fraudSuspicion->setCustomerIp($_SERVER['REMOTE_ADDR'] ?? '');
}
return $fraudSuspicion;
diff --git a/src/Form/Extension/CustomerProfileTypeExtension.php b/src/Form/Extension/CustomerProfileTypeExtension.php
index 36212d6d..85f560cf 100644
--- a/src/Form/Extension/CustomerProfileTypeExtension.php
+++ b/src/Form/Extension/CustomerProfileTypeExtension.php
@@ -20,12 +20,9 @@
final class CustomerProfileTypeExtension extends AbstractTypeExtension
{
- /** @var UserRoleCheckerInterface */
- private $userRoleChecker;
-
- public function __construct(UserRoleCheckerInterface $userRoleChecker)
- {
- $this->userRoleChecker = $userRoleChecker;
+ public function __construct(
+ private readonly UserRoleCheckerInterface $userRoleChecker,
+ ) {
}
public function buildForm(FormBuilderInterface $builder, array $options): void
diff --git a/src/Form/Rule/AutomaticBlacklistingRuleSettingsType.php b/src/Form/Rule/AutomaticBlacklistingRuleSettingsType.php
index 8f5a11cd..ca07c6d8 100644
--- a/src/Form/Rule/AutomaticBlacklistingRuleSettingsType.php
+++ b/src/Form/Rule/AutomaticBlacklistingRuleSettingsType.php
@@ -29,7 +29,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'label' => 'bitbag_sylius_blacklist_plugin.form.automatic_blacklisting_rule.count',
'constraints' => [
new NotBlank(['groups' => ['bitbag']]),
- new Type(['type' => 'numeric', 'groups' => ['bitbag']]),
+ new Type(['type' => 'numeric']),
new Range(['min' => 1, 'groups' => ['bitbag']]),
],
])
@@ -42,8 +42,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'bitbag_sylius_blacklist_plugin.form.automatic_blacklisting_rule.per_month' => AutomaticBlacklistingRuleInterface::PER_MONTH,
],
'attr' => ['style' => 'margin-bottom: 10px;'],
- ])
- ;
+ ]);
}
public function getBlockPrefix(): string
diff --git a/src/Form/Type/AutomaticBlacklistingConfigurationType.php b/src/Form/Type/AutomaticBlacklistingConfigurationType.php
index 044c1767..b4b6279e 100644
--- a/src/Form/Type/AutomaticBlacklistingConfigurationType.php
+++ b/src/Form/Type/AutomaticBlacklistingConfigurationType.php
@@ -12,6 +12,7 @@
namespace BitBag\SyliusBlacklistPlugin\Form\Type;
use BitBag\SyliusBlacklistPlugin\Entity\FraudPrevention\AutomaticBlacklistingRuleInterface;
+use Sylius\Bundle\AdminBundle\Form\Type\AddButtonType;
use Sylius\Bundle\ChannelBundle\Form\Type\ChannelChoiceType;
use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
@@ -20,19 +21,16 @@
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
+use Symfony\UX\LiveComponent\Form\Type\LiveCollectionType;
final class AutomaticBlacklistingConfigurationType extends AbstractResourceType
{
- /** @var array */
- private $attributeChoices;
-
public function __construct(
+ private array $rules,
string $dataClass,
- array $attributeChoices,
array $validationGroups = [],
) {
parent::__construct($dataClass, $validationGroups);
- $this->attributeChoices = $attributeChoices;
}
public function buildForm(FormBuilderInterface $builder, array $options): void
@@ -72,9 +70,19 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
],
'placeholder' => 'bitbag_sylius_blacklist_plugin.ui.choose_time_range',
])
- ->add('rules', AutomaticBlacklistingRuleCollectionType::class, [
- 'label' => 'bitbag_sylius_blacklist_plugin.form.automatic_blacklisting_rule.rules',
- 'button_add_label' => 'sylius.form.promotion.add_rule',
+ ->add('rules', LiveCollectionType::class, [
+ 'entry_type' => AutomaticBlacklistingRuleType::class,
+ 'allow_add' => true,
+ 'allow_delete' => true,
+ 'by_reference' => false,
+ 'button_add_type' => AddButtonType::class,
+ 'button_add_options' => [
+ 'label' => 'sylius.ui.add_rule',
+ 'types' => $this->rules,
+ ],
+ 'button_delete_options' => [
+ 'label' => false,
+ ],
])
;
}
diff --git a/src/Form/Type/AutomaticBlacklistingRuleChoiceType.php b/src/Form/Type/AutomaticBlacklistingRuleChoiceType.php
index b81ab211..810f01f2 100644
--- a/src/Form/Type/AutomaticBlacklistingRuleChoiceType.php
+++ b/src/Form/Type/AutomaticBlacklistingRuleChoiceType.php
@@ -17,12 +17,9 @@
final class AutomaticBlacklistingRuleChoiceType extends AbstractType
{
- /** @var array */
- private $rules;
-
- public function __construct(array $rules)
- {
- $this->rules = $rules;
+ public function __construct(
+ private array $rules,
+ ) {
}
public function configureOptions(OptionsResolver $resolver): void
diff --git a/src/Form/Type/CustomerAutocompleteChoiceType.php b/src/Form/Type/CustomerAutocompleteType.php
similarity index 52%
rename from src/Form/Type/CustomerAutocompleteChoiceType.php
rename to src/Form/Type/CustomerAutocompleteType.php
index a9ce755c..2f2a2e66 100644
--- a/src/Form/Type/CustomerAutocompleteChoiceType.php
+++ b/src/Form/Type/CustomerAutocompleteType.php
@@ -11,39 +11,38 @@
namespace BitBag\SyliusBlacklistPlugin\Form\Type;
-use Sylius\Bundle\ResourceBundle\Form\Type\ResourceAutocompleteChoiceType;
use Symfony\Component\Form\AbstractType;
-use Symfony\Component\Form\FormInterface;
-use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolver;
-
-final class CustomerAutocompleteChoiceType extends AbstractType
+use Symfony\UX\Autocomplete\Form\AsEntityAutocompleteField;
+use Symfony\UX\Autocomplete\Form\BaseEntityAutocompleteType;
+
+#[AsEntityAutocompleteField(
+ alias: 'sylius_admin_customer',
+ route: 'sylius_admin_entity_autocomplete',
+)]
+final class CustomerAutocompleteType extends AbstractType
{
+ public function __construct(
+ private readonly string $customerClass,
+ ) {
+ }
+
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
- 'resource' => 'sylius.customer',
- 'choice_name' => 'email',
+ 'class' => $this->customerClass,
+ 'choice_label' => 'email',
'choice_value' => 'id',
]);
}
- public function buildView(
- FormView $view,
- FormInterface $form,
- array $options,
- ): void {
- $view->vars['remote_criteria_type'] = 'contains';
- $view->vars['remote_criteria_name'] = 'email';
- }
-
public function getBlockPrefix(): string
{
- return 'bitbag_sylius_customer_autocomplete_choice';
+ return 'bitbag_sylius_admin_customer_autocomplete';
}
public function getParent(): string
{
- return ResourceAutocompleteChoiceType::class;
+ return BaseEntityAutocompleteType::class;
}
}
diff --git a/src/Form/Type/FraudSuspicionType.php b/src/Form/Type/FraudSuspicionType.php
index 06dc6b92..daff8526 100644
--- a/src/Form/Type/FraudSuspicionType.php
+++ b/src/Form/Type/FraudSuspicionType.php
@@ -31,12 +31,15 @@ public function __construct(
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
- ->add('customer', CustomerAutocompleteChoiceType::class, [
+ ->add('customer', CustomerAutocompleteType::class, [
'label' => 'sylius.ui.customer',
'priority' => 1,
'constraints' => [
new NotNull(),
],
+ 'attr' => [
+ 'data-test-fraud-suspicion-customer-autocomplete' => '',
+ ],
])
->add('company', TextType::class, [
'required' => false,
diff --git a/src/Menu/AdminOrderShowMenuListener.php b/src/Menu/AdminOrderShowMenuListener.php
index 247825b0..1f5db93e 100644
--- a/src/Menu/AdminOrderShowMenuListener.php
+++ b/src/Menu/AdminOrderShowMenuListener.php
@@ -20,12 +20,10 @@ final class AdminOrderShowMenuListener
/** @var string */
public const MARK_SUSPICIOUS_TYPE_MENU_KEY = 'mark_suspicious';
- /** @var FraudSuspicionRepositoryInterface */
- private $fraudSuspicionRepository;
-
- public function __construct(FraudSuspicionRepositoryInterface $fraudSuspicionRepository)
- {
- $this->fraudSuspicionRepository = $fraudSuspicionRepository;
+ public function __construct(
+ private readonly FraudSuspicionRepositoryInterface $fraudSuspicionRepository,
+ private readonly array $rules,
+ ) {
}
public function addAdminOrderShowMenuItems(MenuBuilderEvent $event): void
diff --git a/src/Menu/FraudPreventionMenuBuilder.php b/src/Menu/FraudPreventionMenuBuilder.php
index c92b4ecd..3fa5369d 100755
--- a/src/Menu/FraudPreventionMenuBuilder.php
+++ b/src/Menu/FraudPreventionMenuBuilder.php
@@ -28,6 +28,7 @@ public function buildMenu(MenuBuilderEvent $menuBuilderEvent): void
$rootMenuItem = $menu
->addChild('bitbag_fraud_prevention')
->setLabel('bitbag_sylius_blacklist_plugin.ui.fraud_prevention')
+ ->setLabelAttribute('icon', 'tabler:spy')
;
$rootMenuItem
@@ -35,7 +36,6 @@ public function buildMenu(MenuBuilderEvent $menuBuilderEvent): void
'route' => 'bitbag_sylius_blacklist_plugin_admin_blacklisting_rule_index',
])
->setLabel('bitbag_sylius_blacklist_plugin.ui.blacklisting_rules')
- ->setLabelAttribute('icon', 'hand paper')
;
$rootMenuItem
@@ -43,7 +43,6 @@ public function buildMenu(MenuBuilderEvent $menuBuilderEvent): void
'route' => 'bitbag_sylius_blacklist_plugin_admin_automatic_blacklisting_configuration_index',
])
->setLabel('bitbag_sylius_blacklist_plugin.ui.automatic_blacklisting_configurations')
- ->setLabelAttribute('icon', 'microchip')
;
$rootMenuItem
@@ -51,7 +50,6 @@ public function buildMenu(MenuBuilderEvent $menuBuilderEvent): void
'route' => 'bitbag_sylius_blacklist_plugin_admin_fraud_suspicion_index',
])
->setLabel('bitbag_sylius_blacklist_plugin.ui.fraud_suspicions')
- ->setLabelAttribute('icon', 'exclamation triangle')
;
$rootMenuItem
@@ -59,7 +57,6 @@ public function buildMenu(MenuBuilderEvent $menuBuilderEvent): void
'route' => 'bitbag_sylius_blacklist_plugin_admin_automatic_blacklisting_configuration_index',
])
->setLabel('bitbag_sylius_blacklist_plugin.ui.automatic_blacklisting_configurations')
- ->setLabelAttribute('icon', 'cog')
;
}
}
diff --git a/src/Processor/AutomaticBlacklistingRulesProcessor.php b/src/Processor/AutomaticBlacklistingRulesProcessor.php
index 61047ab3..568942a3 100644
--- a/src/Processor/AutomaticBlacklistingRulesProcessor.php
+++ b/src/Processor/AutomaticBlacklistingRulesProcessor.php
@@ -24,43 +24,15 @@
class AutomaticBlacklistingRulesProcessor implements AutomaticBlacklistingRulesProcessorInterface
{
- /** @var ServiceRegistryInterface */
- private $serviceRegistry;
-
- /** @var OrderRepositoryInterface */
- private $orderRepository;
-
- /** @var CustomerStateResolverInterface */
- private $customerStateResolver;
-
- /** @var AutomaticBlacklistingConfigurationRepositoryInterface */
- private $automaticBlacklistingConfigurationRepository;
-
- /** @var FraudSuspicionFactoryInterface */
- private $fraudSuspicionFactory;
-
- /** @var FraudSuspicionRepositoryInterface */
- private $fraudSuspicionRepository;
-
- /** @var FraudSuspicionActionEligibilityCheckerInterface */
- private $fraudSuspicionActionEligibilityChecker;
-
public function __construct(
- ServiceRegistryInterface $serviceRegistry,
- OrderRepositoryInterface $orderRepository,
- AutomaticBlacklistingConfigurationRepositoryInterface $automaticBlacklistingConfigurationRepository,
- CustomerStateResolverInterface $customerStateResolver,
- FraudSuspicionFactoryInterface $fraudSuspicionFactory,
- FraudSuspicionRepositoryInterface $fraudSuspicionRepository,
- FraudSuspicionActionEligibilityCheckerInterface $fraudSuspicionActionEligibilityChecker,
+ private readonly ServiceRegistryInterface $serviceRegistry,
+ private readonly OrderRepositoryInterface $orderRepository,
+ private readonly AutomaticBlacklistingConfigurationRepositoryInterface $automaticBlacklistingConfigurationRepository,
+ private readonly CustomerStateResolverInterface $customerStateResolver,
+ private readonly FraudSuspicionFactoryInterface $fraudSuspicionFactory,
+ private readonly FraudSuspicionRepositoryInterface $fraudSuspicionRepository,
+ private readonly FraudSuspicionActionEligibilityCheckerInterface $fraudSuspicionActionEligibilityChecker,
) {
- $this->serviceRegistry = $serviceRegistry;
- $this->orderRepository = $orderRepository;
- $this->automaticBlacklistingConfigurationRepository = $automaticBlacklistingConfigurationRepository;
- $this->customerStateResolver = $customerStateResolver;
- $this->fraudSuspicionFactory = $fraudSuspicionFactory;
- $this->fraudSuspicionRepository = $fraudSuspicionRepository;
- $this->fraudSuspicionActionEligibilityChecker = $fraudSuspicionActionEligibilityChecker;
}
public function process(OrderInterface $order): bool
diff --git a/src/Resolver/AddressTypeResolver.php b/src/Resolver/AddressTypeResolver.php
index ee291ddf..b5ac516e 100644
--- a/src/Resolver/AddressTypeResolver.php
+++ b/src/Resolver/AddressTypeResolver.php
@@ -22,6 +22,22 @@ public function resolveAndUpdateFraudSuspicion(FraudSuspicionInterface $fraudSus
{
$address = $this->resolve($fraudSuspicion);
+ $this->updateFraudSuspicionWithAddress($fraudSuspicion, $address);
+ }
+
+ public function resolve(FraudSuspicionInterface $fraudSuspicion): AddressInterface
+ {
+ $order = $fraudSuspicion->getOrder();
+
+ return match ($fraudSuspicion->getAddressType()) {
+ FraudSuspicion::BILLING_ADDRESS_TYPE => $order->getBillingAddress(),
+ FraudSuspicion::SHIPPING_ADDRESS_TYPE => $order->getShippingAddress(),
+ default => throw new WrongAddressTypeException('Wrong address type!'),
+ };
+ }
+
+ private function updateFraudSuspicionWithAddress(FraudSuspicionInterface $fraudSuspicion, AddressInterface $address): void
+ {
$fraudSuspicion->setFirstName($address->getFirstName());
$fraudSuspicion->setLastName($address->getLastName());
$fraudSuspicion->setCompany($address->getCompany());
@@ -31,16 +47,4 @@ public function resolveAndUpdateFraudSuspicion(FraudSuspicionInterface $fraudSus
$fraudSuspicion->setCountry($address->getCountryCode());
$fraudSuspicion->setPhoneNumber($address->getPhoneNumber());
}
-
- public function resolve(FraudSuspicionInterface $fraudSuspicion): AddressInterface
- {
- switch ($fraudSuspicion->getAddressType()) {
- case FraudSuspicion::BILLING_ADDRESS_TYPE:
- return $fraudSuspicion->getOrder()->getBillingAddress();
- case FraudSuspicion::SHIPPING_ADDRESS_TYPE:
- return $fraudSuspicion->getOrder()->getShippingAddress();
- default:
- throw new WrongAddressTypeException('Wrong address type!');
- }
- }
}
diff --git a/src/Resolver/SuspiciousOrderResolver.php b/src/Resolver/SuspiciousOrderResolver.php
index de20da88..e604f847 100644
--- a/src/Resolver/SuspiciousOrderResolver.php
+++ b/src/Resolver/SuspiciousOrderResolver.php
@@ -24,63 +24,32 @@
class SuspiciousOrderResolver implements SuspiciousOrderResolverInterface
{
- /** @var ServiceRegistryInterface */
- private $serviceRegistry;
-
- /** @var FraudSuspicionRepositoryInterface */
- private $fraudSuspicionRepository;
-
- /** @var BlacklistingRuleRepositoryInterface */
- private $blacklistingRuleRepository;
-
- /** @var ChannelContextInterface */
- private $channelContext;
-
- /** @var ObjectManager */
- private $customerManager;
-
- /** @var BlacklistingRuleEligibilityCheckerInterface */
- private $blacklistingRuleEligibilityChecker;
-
public function __construct(
- ServiceRegistryInterface $serviceRegistry,
- FraudSuspicionRepositoryInterface $fraudSuspicionRepository,
- BlacklistingRuleRepositoryInterface $blacklistingRuleRepository,
- ChannelContextInterface $channelContext,
- ObjectManager $customerManager,
- BlacklistingRuleEligibilityCheckerInterface $blacklistingRuleEligibilityChecker,
+ private readonly ServiceRegistryInterface $serviceRegistry,
+ private readonly FraudSuspicionRepositoryInterface $fraudSuspicionRepository,
+ private readonly BlacklistingRuleRepositoryInterface $blacklistingRuleRepository,
+ private readonly ChannelContextInterface $channelContext,
+ private readonly ObjectManager $customerManager,
+ private readonly BlacklistingRuleEligibilityCheckerInterface $blacklistingRuleEligibilityChecker,
) {
- $this->serviceRegistry = $serviceRegistry;
- $this->fraudSuspicionRepository = $fraudSuspicionRepository;
- $this->blacklistingRuleRepository = $blacklistingRuleRepository;
- $this->channelContext = $channelContext;
- $this->customerManager = $customerManager;
- $this->blacklistingRuleEligibilityChecker = $blacklistingRuleEligibilityChecker;
}
public function resolve(FraudSuspicionCommonModelInterface $fraudSuspicionCommonModel): bool
{
$blacklistingRules = $this->blacklistingRuleRepository->findActiveByChannel($this->getChannel());
- if (0 === \count($blacklistingRules)) {
+ if ([] === $blacklistingRules) {
return false;
}
$customer = $fraudSuspicionCommonModel->getCustomer();
- /** @var BlacklistingRuleInterface $blacklistingRule */
foreach ($blacklistingRules as $blacklistingRule) {
if (!$this->blacklistingRuleEligibilityChecker->isEligible($blacklistingRule, $customer)) {
continue;
}
- $builder = $this->fraudSuspicionRepository->createQueryToLaunchBlacklistingRuleCheckers();
-
- foreach ($blacklistingRule->getAttributes() as $attribute) {
- $this->checkIfCustomerIsBlacklisted($builder, $fraudSuspicionCommonModel, $attribute);
- }
-
- if ((int) ($builder->getQuery()->getSingleScalarResult()) >= $blacklistingRule->getPermittedStrikes()) {
+ if ($this->isCustomerBlacklisted($fraudSuspicionCommonModel, $blacklistingRule)) {
return true;
}
}
@@ -88,13 +57,25 @@ public function resolve(FraudSuspicionCommonModelInterface $fraudSuspicionCommon
return false;
}
- private function checkIfCustomerIsBlacklisted(
+ private function isCustomerBlacklisted(
+ FraudSuspicionCommonModelInterface $fraudSuspicionCommonModel,
+ BlacklistingRuleInterface $blacklistingRule,
+ ): bool {
+ $builder = $this->fraudSuspicionRepository->createQueryToLaunchBlacklistingRuleCheckers();
+
+ foreach ($blacklistingRule->getAttributes() as $attribute) {
+ $this->applyBlacklistingCheck($builder, $fraudSuspicionCommonModel, $attribute);
+ }
+
+ return (int) $builder->getQuery()->getSingleScalarResult() >= $blacklistingRule->getPermittedStrikes();
+ }
+
+ private function applyBlacklistingCheck(
QueryBuilder $builder,
FraudSuspicionCommonModelInterface $fraudSuspicionCommonModel,
string $attribute,
): void {
$checker = $this->serviceRegistry->get($attribute);
-
$checker->checkIfCustomerIsBlacklisted($builder, $fraudSuspicionCommonModel);
}
diff --git a/src/Resources/config/routing.yaml b/src/Resources/config/routing.yaml
deleted file mode 100644
index 99c0b357..00000000
--- a/src/Resources/config/routing.yaml
+++ /dev/null
@@ -1,7 +0,0 @@
-bitbag_sylius_blacklist_plugin_admin:
- resource: "@BitBagSyliusBlacklistPlugin/Resources/config/routing/admin.yaml"
- prefix: /admin
-
-bitbag_sylius_blacklist_plugin_shop:
- resource: "@BitBagSyliusBlacklistPlugin/Resources/config/routing/shop.yaml"
- prefix: /{_locale}
\ No newline at end of file
diff --git a/src/Resources/config/state_machine.yaml b/src/Resources/config/state_machine.yaml
deleted file mode 100644
index 1ebb9b0f..00000000
--- a/src/Resources/config/state_machine.yaml
+++ /dev/null
@@ -1,2 +0,0 @@
-imports:
- - { resource: "state_machine/*.yaml" }
\ No newline at end of file
diff --git a/src/Resources/config/state_machine/customer.yaml b/src/Resources/config/state_machine/customer.yaml
deleted file mode 100644
index bd96a7f8..00000000
--- a/src/Resources/config/state_machine/customer.yaml
+++ /dev/null
@@ -1,19 +0,0 @@
-winzou_state_machine:
- bitbag_sylius_blacklist_plugin_customer:
- class: "%sylius.model.customer.class%"
- property_path: fraudStatus
- graph: bitbag_sylius_blacklist_plugin_customer
- state_machine_class: "%sylius.state_machine.class%"
- states:
- neutral: ~
- blacklisted: ~
- transitions:
- neutralizing:
- from: [blacklisted]
- to: neutral
- blacklisting:
- from: [neutral]
- to: blacklisted
- whitelisting:
- from: [neutral]
- to: whitelisted
\ No newline at end of file
diff --git a/src/Resources/views/AutomaticBlacklistingConfiguration/Admin/_form.html.twig b/src/Resources/views/AutomaticBlacklistingConfiguration/Admin/_form.html.twig
deleted file mode 100644
index f74da1d6..00000000
--- a/src/Resources/views/AutomaticBlacklistingConfiguration/Admin/_form.html.twig
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
- {{ form_errors(form) }}
-
-
-
-
-
-
- {{ form_row(form.name) }}
-
-
- {{ form_row(form.channels) }}
-
-
- {{ form_row(form.enabled) }}
-
-
-
-
-
-
-
-
-
-
- {{ form_row(form.addFraudSuspicion) }}
-
-
- {{ form_row(form.permittedFraudSuspicionsNumber) }}
-
-
- {{ form_row(form.permittedFraudSuspicionsTime) }}
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{ 'bitbag_sylius_blacklist_plugin.ui.rules_are_connected_by_or'|trans }}!
-
-
-
- {{ form_row(form.rules) }}
-
-
-
diff --git a/src/Resources/views/BlacklistingRule/Admin/_form.html.twig b/src/Resources/views/BlacklistingRule/Admin/_form.html.twig
deleted file mode 100644
index 20de1712..00000000
--- a/src/Resources/views/BlacklistingRule/Admin/_form.html.twig
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
- {{ form_errors(form) }}
-
- {{ form_row(form.name) }}
-
-
- {{ form_row(form.channels) }}
-
-
- {{ form_row(form.enabled) }}
-
-
-
-
- {{ form_row(form.attributes) }}
-
-
- {{ form_row(form.permittedStrikes) }}
-
-
-
-
-
- {{ 'bitbag_sylius_blacklist_plugin.form.blacklisting_rule.customer_group_help'|trans }}
-
-
-
- {{ form_label(form.customerGroups) }}
- {{ form_widget(form.customerGroups) }}
- {{ form_row(form.forUnassignedCustomers) }}
-
-
-
-
-
- {{ form_row(form.onlyForGuests) }}
-
-
-
-
diff --git a/src/Resources/views/Form/theme.html.twig b/src/Resources/views/Form/theme.html.twig
deleted file mode 100644
index 2c51bf5f..00000000
--- a/src/Resources/views/Form/theme.html.twig
+++ /dev/null
@@ -1,8 +0,0 @@
-{% extends '@SyliusUi/Form/theme.html.twig' %}
-
-{% block bitbag_sylius_customer_autocomplete_choice_row %}
- {{ form_row(form, {
- 'remote_url': path('bitbag_sylius_blacklist_plugin_admin_ajax_customer_by_email'),
- 'load_edit_url': path('bitbag_sylius_blacklist_plugin_admin_ajax_customer_by_id')
- }) }}
-{% endblock %}
diff --git a/src/Resources/views/FraudSuspicion/Admin/Show/_customer.html.twig b/src/Resources/views/FraudSuspicion/Admin/Show/_customer.html.twig
deleted file mode 100644
index 04cea677..00000000
--- a/src/Resources/views/FraudSuspicion/Admin/Show/_customer.html.twig
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
- {% if fraudSuspicion.customer != null %}
-
-
- {{ fraudSuspicion.customer }}
-
- {% else %}
- {{ 'bitbag_sylius_blacklist_plugin.ui.no_related_customer'|trans }}
- {% endif %}
- |
-
-
-
-
\ No newline at end of file
diff --git a/src/Resources/views/FraudSuspicion/Admin/Show/_details.html.twig b/src/Resources/views/FraudSuspicion/Admin/Show/_details.html.twig
deleted file mode 100644
index d4174963..00000000
--- a/src/Resources/views/FraudSuspicion/Admin/Show/_details.html.twig
+++ /dev/null
@@ -1,85 +0,0 @@
-
-
-
-
-
- {{ 'sylius.ui.company'|trans }}
- |
- {{ fraudSuspicion.company }} |
-
-
- {{ 'sylius.ui.first_name'|trans }}
- |
- {{ fraudSuspicion.firstName }} |
-
-
- {{ 'sylius.ui.last_name'|trans }}
- |
- {{ fraudSuspicion.lastName }} |
-
-
- {{ 'sylius.ui.phone_number'|trans }}
- |
- {{ fraudSuspicion.phoneNumber }} |
-
-
- {{ 'sylius.ui.email'|trans }}
- |
- {{ fraudSuspicion.email }} |
-
-
- {{ 'sylius.ui.street'|trans }}
- |
- {{ fraudSuspicion.street }} |
-
-
- {{ 'sylius.ui.city'|trans }}
- |
- {{ fraudSuspicion.city }} |
-
-
- {{ 'sylius.ui.postcode'|trans }}
- |
- {{ fraudSuspicion.postcode }} |
-
-
- {{ 'sylius.ui.province'|trans }}
- |
- {{ fraudSuspicion.province }} |
-
-
- {{ 'sylius.ui.country'|trans }}
- |
- {{ fraudSuspicion.country }} |
-
-
- {{ 'bitbag_sylius_blacklist_plugin.form.blacklisting_rule.customer_ip'|trans }}
- |
- {{ fraudSuspicion.customerIp }} |
-
-
- {{ 'bitbag_sylius_blacklist_plugin.ui.address_type'|trans }}
- |
- {{ fraudSuspicion.addressType }} |
-
-
- {{ 'bitbag_sylius_blacklist_plugin.form.fraud_suspicion.comment'|trans }}
- |
- {{ fraudSuspicion.comment }} |
-
-
-
-
\ No newline at end of file
diff --git a/src/Resources/views/FraudSuspicion/Admin/Show/_order.html.twig b/src/Resources/views/FraudSuspicion/Admin/Show/_order.html.twig
deleted file mode 100644
index e735d210..00000000
--- a/src/Resources/views/FraudSuspicion/Admin/Show/_order.html.twig
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
\ No newline at end of file
diff --git a/src/Resources/views/FraudSuspicion/Admin/show.html.twig b/src/Resources/views/FraudSuspicion/Admin/show.html.twig
deleted file mode 100644
index 34ac33c4..00000000
--- a/src/Resources/views/FraudSuspicion/Admin/show.html.twig
+++ /dev/null
@@ -1,22 +0,0 @@
-{% extends '@SyliusAdmin/layout.html.twig' %}
-
-{% set fraudSuspicion = resource %}
-
-{% block content %}
- {% include '@BitBagSyliusBlacklistPlugin/FraudSuspicion/Admin/Show/_header.html.twig' %}
-
-
-
-
-
- {% include '@BitBagSyliusBlacklistPlugin/FraudSuspicion/Admin/Show/_customer.html.twig' with {'fraudSuspicion': fraudSuspicion} %}
-
-
- {% include '@BitBagSyliusBlacklistPlugin/FraudSuspicion/Admin/Show/_order.html.twig' with {'fraudSuspicion': fraudSuspicion} %}
-
-
- {% include '@BitBagSyliusBlacklistPlugin/FraudSuspicion/Admin/Show/_details.html.twig' with {'fraudSuspicion': fraudSuspicion} %}
-
-
-{% endblock %}
-
diff --git a/src/StateResolver/CustomerStateResolver.php b/src/StateResolver/CustomerStateResolver.php
index 89965e7d..878ead9a 100644
--- a/src/StateResolver/CustomerStateResolver.php
+++ b/src/StateResolver/CustomerStateResolver.php
@@ -11,35 +11,27 @@
namespace BitBag\SyliusBlacklistPlugin\StateResolver;
-use BitBag\SyliusBlacklistPlugin\Transitions\CustomerTransitions;
use Doctrine\Persistence\ObjectManager;
-use SM\Factory\FactoryInterface;
use Sylius\Component\Customer\Model\CustomerInterface;
+use Symfony\Component\Workflow\WorkflowInterface;
class CustomerStateResolver implements CustomerStateResolverInterface
{
- /** @var FactoryInterface */
- private $stateMachineFactory;
+ public const BLACKLISTING = 'blacklisting';
- /** @var ObjectManager */
- private $customerManager;
-
- public function __construct(FactoryInterface $stateMachineFactory, ObjectManager $customerManager)
- {
- $this->stateMachineFactory = $stateMachineFactory;
- $this->customerManager = $customerManager;
+ public function __construct(
+ private readonly WorkflowInterface $workflow,
+ private readonly ObjectManager $customerManager,
+ ) {
}
public function changeStateOnBlacklisted(CustomerInterface $customer): void
{
- $stateMachine = $this->stateMachineFactory->get($customer, CustomerTransitions::GRAPH);
- $transition = CustomerTransitions::TRANSITION_BLACKLISTING_PROCESS;
-
- if (!$stateMachine->can($transition)) {
+ if (!$this->workflow->can($customer, self::BLACKLISTING)) {
return;
}
- $stateMachine->apply($transition);
+ $this->workflow->apply($customer, self::BLACKLISTING);
$this->customerManager->persist($customer);
$this->customerManager->flush();
diff --git a/src/Transitions/CustomerTransitions.php b/src/Transitions/CustomerTransitions.php
index 238b1819..884212c1 100644
--- a/src/Transitions/CustomerTransitions.php
+++ b/src/Transitions/CustomerTransitions.php
@@ -16,4 +16,8 @@ class CustomerTransitions
public const GRAPH = 'bitbag_sylius_blacklist_plugin_customer';
public const TRANSITION_BLACKLISTING_PROCESS = 'blacklisting';
+
+ public const TRANSITION_NEUTRALIZING_PROCESS = 'neutral';
+
+ public const TRANSITION_WHITELISTING_PROCESS = 'whitelisting';
}
diff --git a/src/Twig/AutomaticBlacklistingConfigurationLabelsExtension.php b/src/Twig/AutomaticBlacklistingConfigurationLabelsExtension.php
new file mode 100644
index 00000000..17835f30
--- /dev/null
+++ b/src/Twig/AutomaticBlacklistingConfigurationLabelsExtension.php
@@ -0,0 +1,38 @@
+ $ruleTypes
+ */
+ public function __construct(
+ private array $ruleTypes,
+ ) {
+ }
+
+ public function getFunctions(): array
+ {
+ return [
+ new TwigFunction('automatic_blacklisting_configuration_get_rule_label', [$this, 'getRuleLabel']),
+ ];
+ }
+
+ public function getRuleLabel(string $type): string
+ {
+ return $this->ruleTypes[$type] ?? '';
+ }
+}
diff --git a/src/Validator/Constraints/AutomaticBlacklistingConfiguration/AddFraudSuspicionWithSettings.php b/src/Validator/Constraints/AutomaticBlacklistingConfiguration/AddFraudSuspicionWithSettings.php
index d5081a99..ea5d3f7c 100644
--- a/src/Validator/Constraints/AutomaticBlacklistingConfiguration/AddFraudSuspicionWithSettings.php
+++ b/src/Validator/Constraints/AutomaticBlacklistingConfiguration/AddFraudSuspicionWithSettings.php
@@ -28,7 +28,7 @@ public function validatedBy(): string
}
/**
- * @return array
+ * @return array{'class'|'property'}
*/
public function getTargets(): array
{
diff --git a/src/Validator/Constraints/BlacklistingRule/BlacklistingRuleCustomerGroups.php b/src/Validator/Constraints/BlacklistingRule/BlacklistingRuleCustomerGroups.php
index 958a2210..e626f3c1 100644
--- a/src/Validator/Constraints/BlacklistingRule/BlacklistingRuleCustomerGroups.php
+++ b/src/Validator/Constraints/BlacklistingRule/BlacklistingRuleCustomerGroups.php
@@ -26,7 +26,7 @@ public function validatedBy(): string
}
/**
- * @return array
+ * @return array{'class'|'property'}
*/
public function getTargets(): array
{
diff --git a/src/Validator/Constraints/Checkout/CheckoutAddressType.php b/src/Validator/Constraints/Checkout/CheckoutAddressType.php
index 892bcff3..48cb7612 100644
--- a/src/Validator/Constraints/Checkout/CheckoutAddressType.php
+++ b/src/Validator/Constraints/Checkout/CheckoutAddressType.php
@@ -26,7 +26,7 @@ public function validatedBy(): string
}
/**
- * @return array
+ * @return array{'class'|'property'}
*/
public function getTargets(): array
{
diff --git a/src/Validator/Constraints/Checkout/CheckoutAddressTypeValidator.php b/src/Validator/Constraints/Checkout/CheckoutAddressTypeValidator.php
index 8cfb641b..a8cc16af 100644
--- a/src/Validator/Constraints/Checkout/CheckoutAddressTypeValidator.php
+++ b/src/Validator/Constraints/Checkout/CheckoutAddressTypeValidator.php
@@ -24,32 +24,24 @@
class CheckoutAddressTypeValidator extends ConstraintValidator
{
- /** @var SuspiciousOrderResolverInterface */
- private $suspiciousOrderResolver;
-
- /** @var AutomaticBlacklistingRulesProcessorInterface */
- private $automaticBlacklistingRulesProcessor;
-
- /** @var FraudSuspicionCommonModelConverterInterface */
- private $fraudSuspicionCommonModelConverter;
-
public function __construct(
- SuspiciousOrderResolverInterface $suspiciousOrderResolver,
- AutomaticBlacklistingRulesProcessorInterface $automaticBlacklistingRulesProcessor,
- FraudSuspicionCommonModelConverterInterface $fraudSuspicionCommonModelConverter,
+ private readonly SuspiciousOrderResolverInterface $suspiciousOrderResolver,
+ private readonly AutomaticBlacklistingRulesProcessorInterface $automaticBlacklistingRulesProcessor,
+ private readonly FraudSuspicionCommonModelConverterInterface $fraudSuspicionCommonModelConverter,
) {
- $this->suspiciousOrderResolver = $suspiciousOrderResolver;
- $this->automaticBlacklistingRulesProcessor = $automaticBlacklistingRulesProcessor;
- $this->fraudSuspicionCommonModelConverter = $fraudSuspicionCommonModelConverter;
}
public function validate(mixed $order, Constraint $constraint): void
{
Assert::isInstanceOf($order, OrderInterface::class);
- /** @var CustomerInterface $customer */
+ /** @var CustomerInterface|null $customer */
$customer = $order->getCustomer();
+ if (null === $customer) {
+ return;
+ }
+
if (FraudStatusInterface::FRAUD_STATUS_WHITELISTED === $customer->getFraudStatus()) {
return;
}
diff --git a/templates/AutomaticBlacklistingConfiguration/Admin/form.html.twig b/templates/AutomaticBlacklistingConfiguration/Admin/form.html.twig
new file mode 100644
index 00000000..3e802278
--- /dev/null
+++ b/templates/AutomaticBlacklistingConfiguration/Admin/form.html.twig
@@ -0,0 +1,53 @@
+{% form_theme form '@BitBagSyliusBlacklistPlugin/Form/theme.html.twig' %}
+
+
+ {{ form_start(form, {'attr': {'class': 'ui loadable form', 'novalidate': 'novalidate', 'id': form.vars.id}}) }}
+ {% if hookable_metadata.configuration.method is defined %}
+
+ {% endif %}
+ {{ form_errors(form) }}
+ {{ form_widget(form._token) }}
+
+
+
+
+
+
+ {{ form_row(form.name) }}
+
+
+ {{ form_row(form.channels) }}
+
+
+ {{ form_row(form.enabled) }}
+
+
+ {{ form_row(form.addFraudSuspicion) }}
+
+
+ {{ form_row(form.permittedFraudSuspicionsNumber) }}
+
+
+ {{ form_row(form.permittedFraudSuspicionsTime) }}
+
+
+
+
+
+
+
+
+
+
+ {{ form_row(form.rules, {label: false}) }}
+
+
+
+
+
+ {{ form_end(form, {render_rest: hookable.configuration.render_rest|default(false)}) }}
+
diff --git a/src/Resources/views/BlacklistingRule/Admin/Grid/Field/attributes.html.twig b/templates/BlacklistingRule/Admin/Grid/Field/attributes.html.twig
similarity index 100%
rename from src/Resources/views/BlacklistingRule/Admin/Grid/Field/attributes.html.twig
rename to templates/BlacklistingRule/Admin/Grid/Field/attributes.html.twig
diff --git a/templates/BlacklistingRule/Admin/form.html.twig b/templates/BlacklistingRule/Admin/form.html.twig
new file mode 100644
index 00000000..d376e140
--- /dev/null
+++ b/templates/BlacklistingRule/Admin/form.html.twig
@@ -0,0 +1,44 @@
+{% form_theme form '@BitBagSyliusBlacklistPlugin/Form/theme.html.twig' %}
+
+
+ {{ form_start(form, {'attr': {'class': 'ui loadable form', 'novalidate': 'novalidate', 'id': form.vars.id}}) }}
+ {% if hookable_metadata.configuration.method is defined %}
+
+ {% endif %}
+ {{ form_errors(form) }}
+ {{ form_widget(form._token) }}
+
+
+
+
+
+
+ {{ form_row(form.name) }}
+
+
+ {{ form_row(form.channels) }}
+
+
+ {{ form_row(form.enabled) }}
+
+
+ {{ form_row(form.attributes) }}
+
+
+ {{ form_row(form.permittedStrikes) }}
+
+
+ {{ form_row(form.customerGroups) }}
+
+
+ {{ form_row(form.forUnassignedCustomers) }}
+
+
+ {{ form_row(form.onlyForGuests) }}
+
+
+
+
+
diff --git a/templates/Customer/Form/Sections/extra_information.html.twig b/templates/Customer/Form/Sections/extra_information.html.twig
new file mode 100644
index 00000000..dd6ddb79
--- /dev/null
+++ b/templates/Customer/Form/Sections/extra_information.html.twig
@@ -0,0 +1,13 @@
+
+
+
+
+ {% hook 'extra_information' %}
+ {{ form_row(hookable_metadata.context.form.fraudStatus) }}
+
+
+
diff --git a/src/Resources/views/Customer/Grid/Field/fraudStatus.html.twig b/templates/Customer/Grid/Field/fraudStatus.html.twig
similarity index 100%
rename from src/Resources/views/Customer/Grid/Field/fraudStatus.html.twig
rename to templates/Customer/Grid/Field/fraudStatus.html.twig
diff --git a/templates/Form/theme.html.twig b/templates/Form/theme.html.twig
new file mode 100644
index 00000000..783e0720
--- /dev/null
+++ b/templates/Form/theme.html.twig
@@ -0,0 +1,34 @@
+{% extends '@SyliusAdmin/shared/form_theme.html.twig' %}
+
+{%- block bitbag_sylius_blacklist_plugin_automatic_blacklisting_rule_row -%}
+
+ {{- form_errors(form) -}}
+ {{- form_row(form.type) -}}
+
+
+
{{ automatic_blacklisting_configuration_get_rule_label(form.type.vars.data)|trans }}
+ {{- form_row(button_delete, sylius_test_form_attribute('delete')|sylius_merge_recursive({'attr': {'class': 'btn-close'}})) -}}
+
+
+ {{- form_row(form.settings, {'label': false}) -}}
+
+
+
+{%- endblock bitbag_sylius_blacklist_plugin_automatic_blacklisting_rule_row -%}
+
+{% block add_button_row %}
+ {% if types is not empty %}
+
+
+
+
+ {% endif %}
+{% endblock %}
diff --git a/src/Resources/views/FraudSuspicion/Admin/Grid/Field/order.html.twig b/templates/FraudSuspicion/Admin/Grid/Field/order.html.twig
similarity index 100%
rename from src/Resources/views/FraudSuspicion/Admin/Grid/Field/order.html.twig
rename to templates/FraudSuspicion/Admin/Grid/Field/order.html.twig
diff --git a/templates/FraudSuspicion/Admin/Show/_customer.html.twig b/templates/FraudSuspicion/Admin/Show/_customer.html.twig
new file mode 100644
index 00000000..132edec1
--- /dev/null
+++ b/templates/FraudSuspicion/Admin/Show/_customer.html.twig
@@ -0,0 +1,14 @@
+
+
+
+ {% if fraudSuspicion.customer != null %}
+
+ {{ fraudSuspicion.customer }}
+
+ {% else %}
+
{{ 'bitbag_sylius_blacklist_plugin.ui.no_related_customer'|trans }}
+ {% endif %}
+
+
diff --git a/templates/FraudSuspicion/Admin/Show/_details.html.twig b/templates/FraudSuspicion/Admin/Show/_details.html.twig
new file mode 100644
index 00000000..aedb9456
--- /dev/null
+++ b/templates/FraudSuspicion/Admin/Show/_details.html.twig
@@ -0,0 +1,75 @@
+
+
+
+
+
+
+ {{ 'sylius.ui.company'|trans }} |
+ {{ fraudSuspicion.company }} |
+
+
+ {{ 'sylius.ui.first_name'|trans }} |
+ {{ fraudSuspicion.firstName }} |
+
+
+ {{ 'sylius.ui.last_name'|trans }} |
+ {{ fraudSuspicion.lastName }} |
+
+
+ {{ 'sylius.ui.phone_number'|trans }} |
+ {{ fraudSuspicion.phoneNumber }} |
+
+
+ {{ 'sylius.ui.email'|trans }} |
+ {{ fraudSuspicion.email }} |
+
+
+ {{ 'sylius.ui.street'|trans }} |
+ {{ fraudSuspicion.street }} |
+
+
+ {{ 'sylius.ui.city'|trans }} |
+ {{ fraudSuspicion.city }} |
+
+
+ {{ 'sylius.ui.postcode'|trans }} |
+ {{ fraudSuspicion.postcode }} |
+
+
+ {{ 'sylius.ui.province'|trans }} |
+ {{ fraudSuspicion.province }} |
+
+
+ {{ 'sylius.ui.country'|trans }} |
+ {{ fraudSuspicion.country }} |
+
+
+
+
+ {{ 'bitbag_sylius_blacklist_plugin.form.blacklisting_rule.customer_ip'|trans }}
+
+ |
+ {{ fraudSuspicion.customerIp }} |
+
+
+
+
+ {{ 'bitbag_sylius_blacklist_plugin.ui.address_type'|trans }}
+
+ |
+ {{ fraudSuspicion.addressType }} |
+
+
+
+
+ {{ 'bitbag_sylius_blacklist_plugin.form.fraud_suspicion.comment'|trans }}
+
+ |
+ {{ fraudSuspicion.comment }} |
+
+
+
+
+
diff --git a/src/Resources/views/FraudSuspicion/Admin/Show/_header.html.twig b/templates/FraudSuspicion/Admin/Show/_header.html.twig
similarity index 100%
rename from src/Resources/views/FraudSuspicion/Admin/Show/_header.html.twig
rename to templates/FraudSuspicion/Admin/Show/_header.html.twig
diff --git a/templates/FraudSuspicion/Admin/Show/_order.html.twig b/templates/FraudSuspicion/Admin/Show/_order.html.twig
new file mode 100644
index 00000000..6d26b12d
--- /dev/null
+++ b/templates/FraudSuspicion/Admin/Show/_order.html.twig
@@ -0,0 +1,17 @@
+
+
diff --git a/templates/FraudSuspicion/Admin/form.html.twig b/templates/FraudSuspicion/Admin/form.html.twig
new file mode 100644
index 00000000..b3b93ad6
--- /dev/null
+++ b/templates/FraudSuspicion/Admin/form.html.twig
@@ -0,0 +1,59 @@
+{% form_theme form '@BitBagSyliusBlacklistPlugin/Form/theme.html.twig' %}
+
+
+ {{ form_start(form, {'attr': {'class': 'ui loadable form', 'novalidate': 'novalidate', 'id': form.vars.id}}) }}
+ {% if hookable_metadata.configuration.method is defined %}
+
+ {% endif %}
+ {{ form_errors(form) }}
+ {{ form_widget(form._token) }}
+
+
+
+
+
+
+ {{ form_row(form.customer) }}
+
+
+ {{ form_row(form.company) }}
+
+
+ {{ form_row(form.firstName) }}
+
+
+ {{ form_row(form.lastName) }}
+
+
+ {{ form_row(form.email) }}
+
+
+ {{ form_row(form.street) }}
+
+
+ {{ form_row(form.city) }}
+
+
+ {{ form_row(form.province) }}
+
+
+ {{ form_row(form.country) }}
+
+
+ {{ form_row(form.postcode) }}
+
+
+ {{ form_row(form.customerIp) }}
+
+
+ {{ form_row(form.addressType) }}
+
+
+ {{ form_row(form.comment) }}
+
+
+
+
+
diff --git a/templates/FraudSuspicion/Admin/show.html.twig b/templates/FraudSuspicion/Admin/show.html.twig
new file mode 100644
index 00000000..774b821d
--- /dev/null
+++ b/templates/FraudSuspicion/Admin/show.html.twig
@@ -0,0 +1,16 @@
+{% set fraudSuspicion = hookable_metadata.context.resource %}
+
+
+
+
+ {% include '@BitBagSyliusBlacklistPlugin/FraudSuspicion/Admin/Show/_customer.html.twig' with {'fraudSuspicion': fraudSuspicion} %}
+
+
+ {% include '@BitBagSyliusBlacklistPlugin/FraudSuspicion/Admin/Show/_order.html.twig' with {'fraudSuspicion': fraudSuspicion} %}
+
+
+ {% include '@BitBagSyliusBlacklistPlugin/FraudSuspicion/Admin/Show/_details.html.twig' with {'fraudSuspicion': fraudSuspicion} %}
+
+
+
+
diff --git a/templates/Order/Show/Content/Header/Title_block/actions.html.twig b/templates/Order/Show/Content/Header/Title_block/actions.html.twig
new file mode 100644
index 00000000..563a48a3
--- /dev/null
+++ b/templates/Order/Show/Content/Header/Title_block/actions.html.twig
@@ -0,0 +1,19 @@
+{% set resource = hookable_metadata.context.resource %}
+
+
diff --git a/tests/Application/.babelrc b/tests/Application/.babelrc
deleted file mode 100644
index e563a62e..00000000
--- a/tests/Application/.babelrc
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "presets": [
- ["env", {
- "targets": {
- "node": "6"
- },
- "useBuiltIns": true
- }]
- ],
- "plugins": [
- ["transform-object-rest-spread", {
- "useBuiltIns": true
- }]
- ]
-}
diff --git a/tests/Application/Kernel.php b/tests/Application/Kernel.php
index f72d72c1..cc184857 100644
--- a/tests/Application/Kernel.php
+++ b/tests/Application/Kernel.php
@@ -5,7 +5,7 @@
namespace Tests\BitBag\SyliusBlacklistPlugin\Application;
use PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer;
-use Sylius\Bundle\CoreBundle\Application\Kernel as SyliusKernel;
+use Sylius\Bundle\CoreBundle\SyliusCoreBundle;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\Config\Resource\FileResource;
@@ -113,13 +113,5 @@ private function registerBundlesFromFile(string $bundlesFile): iterable
private function getConfigurationDirectories(): iterable
{
yield $this->getProjectDir() . '/config';
- $syliusConfigDir = $this->getProjectDir() . '/config/sylius/' . SyliusKernel::MAJOR_VERSION . '.' . SyliusKernel::MINOR_VERSION;
- if (is_dir($syliusConfigDir)) {
- yield $syliusConfigDir;
- }
- $symfonyConfigDir = $this->getProjectDir() . '/config/symfony/' . BaseKernel::MAJOR_VERSION . '.' . BaseKernel::MINOR_VERSION;
- if (is_dir($symfonyConfigDir)) {
- yield $symfonyConfigDir;
- }
}
}
diff --git a/tests/Application/assets/admin/entry.js b/tests/Application/assets/admin/entry.js
index 635f5acc..063df3e0 100644
--- a/tests/Application/assets/admin/entry.js
+++ b/tests/Application/assets/admin/entry.js
@@ -1 +1 @@
-import 'sylius/bundle/AdminBundle/Resources/private/entry';
+import 'sylius/bundle/AdminBundle/Resources/assets/entrypoint';
diff --git a/tests/Application/assets/admin/product-entry.js b/tests/Application/assets/admin/product-entry.js
new file mode 100644
index 00000000..eda48352
--- /dev/null
+++ b/tests/Application/assets/admin/product-entry.js
@@ -0,0 +1 @@
+import 'sylius/bundle/AdminBundle/Resources/assets/scripts/product/attribute-tabs-refresher';
diff --git a/tests/Application/assets/controllers.json b/tests/Application/assets/controllers.json
new file mode 100644
index 00000000..8428b1fa
--- /dev/null
+++ b/tests/Application/assets/controllers.json
@@ -0,0 +1,17 @@
+{
+ "controllers": {
+ "@symfony/ux-autocomplete": {
+ "autocomplete": {
+ "main": "dist/controller.js",
+ "webpackMode": "eager",
+ "fetch": "eager",
+ "enabled": true,
+ "autoimport": {
+ "tom-select/dist/css/tom-select.default.css": false,
+ "tom-select/dist/css/tom-select.bootstrap5.css": false
+ }
+ }
+ }
+ },
+ "entrypoints": []
+}
diff --git a/tests/Application/assets/shop/entry.js b/tests/Application/assets/shop/entry.js
index aadc3174..dbb7d931 100644
--- a/tests/Application/assets/shop/entry.js
+++ b/tests/Application/assets/shop/entry.js
@@ -1 +1 @@
-import 'sylius/bundle/ShopBundle/Resources/private/entry';
+import 'sylius/bundle/ShopBundle/Resources/assets/entrypoint';
diff --git a/tests/Application/config/bundles.php b/tests/Application/config/bundles.php
index 77b90df6..40be751d 100644
--- a/tests/Application/config/bundles.php
+++ b/tests/Application/config/bundles.php
@@ -35,16 +35,12 @@
Sylius\Bundle\CoreBundle\SyliusCoreBundle::class => ['all' => true],
Sylius\Bundle\ResourceBundle\SyliusResourceBundle::class => ['all' => true],
Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true],
- winzou\Bundle\StateMachineBundle\winzouStateMachineBundle::class => ['all' => true],
- Sonata\BlockBundle\SonataBlockBundle::class => ['all' => true],
- Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle::class => ['all' => true],
- JMS\SerializerBundle\JMSSerializerBundle::class => ['all' => true],
- FOS\RestBundle\FOSRestBundle::class => ['all' => true],
Knp\Bundle\GaufretteBundle\KnpGaufretteBundle::class => ['all' => true],
Knp\Bundle\MenuBundle\KnpMenuBundle::class => ['all' => true],
Liip\ImagineBundle\LiipImagineBundle::class => ['all' => true],
Payum\Bundle\PayumBundle\PayumBundle::class => ['all' => true],
Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true],
+ BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true],
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
Sylius\Bundle\FixturesBundle\SyliusFixturesBundle::class => ['all' => true],
Sylius\Bundle\PayumBundle\SyliusPayumBundle::class => ['all' => true],
@@ -54,17 +50,22 @@
BitBag\SyliusBlacklistPlugin\BitBagSyliusBlacklistPlugin::class => ['all' => true],
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true],
+ Fidry\AliceDataFixtures\Bridge\Symfony\FidryAliceDataFixturesBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true],
+ Nelmio\Alice\Bridge\Symfony\NelmioAliceBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true],
FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class => ['test' => true, 'test_cached' => true],
Sylius\Behat\Application\SyliusTestPlugin\SyliusTestPlugin::class => ['test' => true, 'test_cached' => true],
- ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true],
+ ApiPlatform\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true],
Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true],
Sylius\Bundle\ApiBundle\SyliusApiBundle::class => ['all' => true],
SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true],
- Nelmio\Alice\Bridge\Symfony\NelmioAliceBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true],
- Fidry\AliceDataFixtures\Bridge\Symfony\FidryAliceDataFixturesBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true],
- Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true],
League\FlysystemBundle\FlysystemBundle::class => ['all' => true],
- Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true],
- BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true],
- SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true],
+ Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true],
+ Sylius\TwigHooks\SyliusTwigHooksBundle::class => ['all' => true],
+ Symfony\UX\TwigComponent\TwigComponentBundle::class => ['all' => true],
+ Symfony\UX\LiveComponent\LiveComponentBundle::class => ['all' => true],
+ Symfony\UX\Autocomplete\AutocompleteBundle::class => ['all' => true],
+ Symfony\UX\StimulusBundle\StimulusBundle::class => ['all' => true],
+ Sylius\TwigExtra\Symfony\SyliusTwigExtraBundle::class => ['all' => true],
+ Symfony\UX\Icons\UXIconsBundle::class => ['all' => true],
+ Sylius\Abstraction\StateMachine\SyliusStateMachineAbstractionBundle::class => ['all' => true],
];
diff --git a/tests/Application/config/packages/_sylius.yaml b/tests/Application/config/packages/_sylius.yaml
index be721c05..3fc8cfb1 100644
--- a/tests/Application/config/packages/_sylius.yaml
+++ b/tests/Application/config/packages/_sylius.yaml
@@ -1,23 +1,28 @@
imports:
- { resource: "@SyliusCoreBundle/Resources/config/app/config.yml" }
-
+ - { resource: "@SyliusPayumBundle/Resources/config/app/config.yaml" }
- { resource: "@SyliusAdminBundle/Resources/config/app/config.yml" }
-
- { resource: "@SyliusShopBundle/Resources/config/app/config.yml" }
-
- { resource: "@SyliusApiBundle/Resources/config/app/config.yaml" }
-
- - { resource: "@BitBagSyliusBlacklistPlugin/Resources/config/config.yaml" }
-
- { resource: "../../src/Resources/config/config.yaml" }
parameters:
sylius_core.public_dir: '%kernel.project_dir%/public'
+ test_default_state_machine_adapter: 'symfony_workflow'
+ test_sylius_state_machine_adapter: '%env(string:default:test_default_state_machine_adapter:TEST_SYLIUS_STATE_MACHINE_ADAPTER)%'
sylius_shop:
product_grid:
include_all_descendants: true
+sylius_state_machine_abstraction:
+ default_adapter: '%test_sylius_state_machine_adapter%'
+ graphs_to_adapters_mapping:
+ sylius_refund_refund_payment: '%test_sylius_state_machine_adapter%'
+
+sylius_api:
+ enabled: true
+
sylius_grid:
grids:
sylius_admin_customer:
diff --git a/tests/Application/config/packages/bitbag_sylius_blacklist_plugin.yaml b/tests/Application/config/packages/bitbag_sylius_blacklist_plugin.yaml
index 2500c089..ed4b46cc 100644
--- a/tests/Application/config/packages/bitbag_sylius_blacklist_plugin.yaml
+++ b/tests/Application/config/packages/bitbag_sylius_blacklist_plugin.yaml
@@ -1,2 +1,2 @@
imports:
- - { resource: "@BitBagSyliusBlacklistPlugin/Resources/config/config.yaml" }
+ - { resource: "@BitBagSyliusBlacklistPlugin/config/config.yaml" }
diff --git a/tests/Application/config/packages/doctrine.yaml b/tests/Application/config/packages/doctrine.yaml
index 89b80d63..a6adc48f 100644
--- a/tests/Application/config/packages/doctrine.yaml
+++ b/tests/Application/config/packages/doctrine.yaml
@@ -22,4 +22,4 @@ doctrine:
is_bundle: false
type: xml
dir: '%kernel.project_dir%/src/Resources/config/doctrine'
- prefix: 'Tests\BitBag\SyliusBlacklistPlugin\Entity'
\ No newline at end of file
+ prefix: 'Tests\BitBag\SyliusBlacklistPlugin\Entity'
diff --git a/tests/Application/config/packages/fos_rest.yaml b/tests/Application/config/packages/fos_rest.yaml
deleted file mode 100644
index a72eef7c..00000000
--- a/tests/Application/config/packages/fos_rest.yaml
+++ /dev/null
@@ -1,11 +0,0 @@
-fos_rest:
- exception: true
- view:
- formats:
- json: true
- xml: true
- empty_content: 204
- format_listener:
- rules:
- - { path: '^/api/.*', priorities: ['json', 'xml'], fallback_format: json, prefer_extension: true }
- - { path: '^/', stop: true }
diff --git a/tests/Application/config/packages/http_discovery.yaml b/tests/Application/config/packages/http_discovery.yaml
new file mode 100644
index 00000000..8be5f3d8
--- /dev/null
+++ b/tests/Application/config/packages/http_discovery.yaml
@@ -0,0 +1,10 @@
+services:
+ Psr\Http\Message\RequestFactoryInterface: '@http_discovery.psr17_factory'
+ Psr\Http\Message\ResponseFactoryInterface: '@http_discovery.psr17_factory'
+ Psr\Http\Message\ServerRequestFactoryInterface: '@http_discovery.psr17_factory'
+ Psr\Http\Message\StreamFactoryInterface: '@http_discovery.psr17_factory'
+ Psr\Http\Message\UploadedFileFactoryInterface: '@http_discovery.psr17_factory'
+ Psr\Http\Message\UriFactoryInterface: '@http_discovery.psr17_factory'
+
+ http_discovery.psr17_factory:
+ class: Http\Discovery\Psr17Factory
diff --git a/tests/Application/config/sylius/1.12/packages/security.yaml b/tests/Application/config/packages/security.yaml
similarity index 75%
rename from tests/Application/config/sylius/1.12/packages/security.yaml
rename to tests/Application/config/packages/security.yaml
index 842b093c..f8719805 100644
--- a/tests/Application/config/sylius/1.12/packages/security.yaml
+++ b/tests/Application/config/packages/security.yaml
@@ -1,5 +1,4 @@
security:
- enable_authenticator_manager: true
providers:
sylius_admin_user_provider:
id: sylius.admin_user_provider.email_or_name_based
@@ -40,12 +39,12 @@ security:
target: sylius_admin_login
new_api_admin_user:
- pattern: "%sylius.security.new_api_admin_regex%/.*"
+ pattern: "%sylius.security.api_admin_regex%/.*"
provider: sylius_api_admin_user_provider
stateless: true
entry_point: jwt
json_login:
- check_path: "%sylius.security.new_api_admin_route%/authentication-token"
+ check_path: "%sylius.security.api_admin_route%/authentication-token"
username_path: email
password_path: password
success_handler: lexik_jwt_authentication.handler.authentication_success
@@ -53,12 +52,12 @@ security:
jwt: true
new_api_shop_user:
- pattern: "%sylius.security.new_api_shop_regex%/.*"
+ pattern: "%sylius.security.api_shop_regex%/.*"
provider: sylius_api_shop_user_provider
stateless: true
entry_point: jwt
json_login:
- check_path: "%sylius.security.new_api_shop_route%/authentication-token"
+ check_path: "%sylius.security.api_shop_route%/authentication-token"
username_path: email
password_path: password
success_handler: lexik_jwt_authentication.handler.authentication_success
@@ -102,10 +101,7 @@ security:
security: false
access_control:
- - { path: "%sylius.security.admin_regex%/_partial", role: PUBLIC_ACCESS, ips: [127.0.0.1, ::1] }
- - { path: "%sylius.security.admin_regex%/_partial", role: ROLE_NO_ACCESS }
- - { path: "%sylius.security.shop_regex%/_partial", role: PUBLIC_ACCESS, ips: [127.0.0.1, ::1] }
- - { path: "%sylius.security.shop_regex%/_partial", role: ROLE_NO_ACCESS }
+ - { path: "%sylius.security.admin_regex%/forgotten-password", role: PUBLIC_ACCESS }
- { path: "%sylius.security.admin_regex%/login", role: PUBLIC_ACCESS }
- { path: "%sylius.security.shop_regex%/login", role: PUBLIC_ACCESS }
@@ -116,9 +112,9 @@ security:
- { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS }
- { path: "%sylius.security.shop_regex%/account", role: ROLE_USER }
- - { path: "%sylius.security.new_api_admin_route%/reset-password-requests", role: PUBLIC_ACCESS }
- - { path: "%sylius.security.new_api_admin_regex%/.*", role: ROLE_API_ACCESS }
- - { path: "%sylius.security.new_api_admin_route%/authentication-token", role: PUBLIC_ACCESS }
- - { path: "%sylius.security.new_api_user_account_regex%/.*", role: ROLE_USER }
- - { path: "%sylius.security.new_api_shop_route%/authentication-token", role: PUBLIC_ACCESS }
- - { path: "%sylius.security.new_api_shop_regex%/.*", role: PUBLIC_ACCESS }
+ - { path: "%sylius.security.api_admin_route%/administrators/reset-password", role: PUBLIC_ACCESS }
+ - { path: "%sylius.security.api_admin_regex%/.*", role: ROLE_API_ACCESS }
+ - { path: "%sylius.security.api_admin_route%/administrators/token", role: PUBLIC_ACCESS }
+ - { path: "%sylius.security.api_shop_account_regex%/.*", role: ROLE_USER }
+ - { path: "%sylius.security.api_shop_route%/customers/token", role: PUBLIC_ACCESS }
+ - { path: "%sylius.security.api_shop_regex%/.*", role: PUBLIC_ACCESS }
diff --git a/tests/Application/config/packages/twig.yaml b/tests/Application/config/packages/twig.yaml
index 68fe7492..9f1fca52 100644
--- a/tests/Application/config/packages/twig.yaml
+++ b/tests/Application/config/packages/twig.yaml
@@ -4,7 +4,6 @@ twig:
strict_variables: '%kernel.debug%'
form_themes:
- '@BitBagSyliusBlacklistPlugin/Form/theme.html.twig'
- - '@SyliusUi/Form/theme.html.twig'
services:
_defaults:
diff --git a/tests/Application/config/packages/validator.yaml b/tests/Application/config/packages/validator.yaml
index 61807db6..bad0ccd7 100644
--- a/tests/Application/config/packages/validator.yaml
+++ b/tests/Application/config/packages/validator.yaml
@@ -1,3 +1,4 @@
framework:
validation:
- enable_annotations: true
+ enable_attributes: true
+ email_validation_mode: strict
diff --git a/tests/Application/config/routes.yaml b/tests/Application/config/routes.yaml
index 85666bef..01642363 100644
--- a/tests/Application/config/routes.yaml
+++ b/tests/Application/config/routes.yaml
@@ -1,2 +1,2 @@
bitbag_sylius_blacklist_plugin:
- resource: "@BitBagSyliusBlacklistPlugin/Resources/config/routing.yaml"
\ No newline at end of file
+ resource: "@BitBagSyliusBlacklistPlugin/config/routing.yaml"
diff --git a/tests/Application/config/routes/sylius_api.yaml b/tests/Application/config/routes/sylius_api.yaml
index ae01ffce..a7504e86 100644
--- a/tests/Application/config/routes/sylius_api.yaml
+++ b/tests/Application/config/routes/sylius_api.yaml
@@ -1,3 +1,3 @@
sylius_api:
resource: "@SyliusApiBundle/Resources/config/routing.yml"
- prefix: "%sylius.security.new_api_route%"
+ prefix: "%sylius.security.api_route%"
diff --git a/tests/Application/config/routes/sylius_shop.yaml b/tests/Application/config/routes/sylius_shop.yaml
index fae46cbf..4f6ac73c 100644
--- a/tests/Application/config/routes/sylius_shop.yaml
+++ b/tests/Application/config/routes/sylius_shop.yaml
@@ -5,7 +5,7 @@ sylius_shop:
_locale: ^[A-Za-z]{2,4}(_([A-Za-z]{4}|[0-9]{3}))?(_([A-Za-z]{2}|[0-9]{3}))?$
sylius_shop_payum:
- resource: "@SyliusShopBundle/Resources/config/routing/payum.yml"
+ resource: "@SyliusPayumBundle/Resources/config/routing/integrations/sylius_shop.yaml"
sylius_shop_default_locale:
path: /
diff --git a/tests/Application/config/routes/ux.yaml b/tests/Application/config/routes/ux.yaml
new file mode 100644
index 00000000..6acafc2c
--- /dev/null
+++ b/tests/Application/config/routes/ux.yaml
@@ -0,0 +1,3 @@
+live_component:
+ resource: "@LiveComponentBundle/config/routes.php"
+ prefix: /{_locale}/_components
diff --git a/tests/Application/config/sylius/1.13/bundles.php b/tests/Application/config/sylius/1.13/bundles.php
deleted file mode 100644
index e615f85b..00000000
--- a/tests/Application/config/sylius/1.13/bundles.php
+++ /dev/null
@@ -1,14 +0,0 @@
- ['all' => true],
-];
diff --git a/tests/Application/config/sylius/1.13/packages/_sylius.yaml b/tests/Application/config/sylius/1.13/packages/_sylius.yaml
deleted file mode 100644
index baa3d7ed..00000000
--- a/tests/Application/config/sylius/1.13/packages/_sylius.yaml
+++ /dev/null
@@ -1,10 +0,0 @@
-parameters:
- test_default_state_machine_adapter: 'symfony_workflow'
- test_sylius_state_machine_adapter: '%env(string:default:test_default_state_machine_adapter:TEST_SYLIUS_STATE_MACHINE_ADAPTER)%'
-
-sylius_state_machine_abstraction:
- graphs_to_adapters_mapping:
- sylius_refund_refund_payment: '%test_sylius_state_machine_adapter%'
-
-sylius_api:
- enabled: true
diff --git a/tests/Application/config/sylius/1.13/packages/security.yaml b/tests/Application/config/sylius/1.13/packages/security.yaml
deleted file mode 100644
index 4ed342f8..00000000
--- a/tests/Application/config/sylius/1.13/packages/security.yaml
+++ /dev/null
@@ -1,124 +0,0 @@
-security:
- enable_authenticator_manager: true
- providers:
- sylius_admin_user_provider:
- id: sylius.admin_user_provider.email_or_name_based
- sylius_api_admin_user_provider:
- id: sylius.admin_user_provider.email_or_name_based
- sylius_shop_user_provider:
- id: sylius.shop_user_provider.email_or_name_based
- sylius_api_shop_user_provider:
- id: sylius.shop_user_provider.email_or_name_based
-
- password_hashers:
- Sylius\Component\User\Model\UserInterface: argon2i
- firewalls:
- admin:
- switch_user: true
- context: admin
- pattern: "%sylius.security.admin_regex%"
- provider: sylius_admin_user_provider
- form_login:
- provider: sylius_admin_user_provider
- login_path: sylius_admin_login
- check_path: sylius_admin_login_check
- failure_path: sylius_admin_login
- default_target_path: sylius_admin_dashboard
- use_forward: false
- use_referer: true
- enable_csrf: true
- csrf_parameter: _csrf_admin_security_token
- csrf_token_id: admin_authenticate
- remember_me:
- secret: "%env(APP_SECRET)%"
- path: "/%sylius_admin.path_name%"
- name: APP_ADMIN_REMEMBER_ME
- lifetime: 31536000
- remember_me_parameter: _remember_me
- logout:
- path: sylius_admin_logout
- target: sylius_admin_login
-
- new_api_admin_user:
- pattern: "%sylius.security.new_api_admin_regex%/.*"
- provider: sylius_api_admin_user_provider
- stateless: true
- entry_point: jwt
- json_login:
- check_path: "%sylius.security.new_api_admin_route%/authentication-token"
- username_path: email
- password_path: password
- success_handler: lexik_jwt_authentication.handler.authentication_success
- failure_handler: lexik_jwt_authentication.handler.authentication_failure
- jwt: true
-
- new_api_shop_user:
- pattern: "%sylius.security.new_api_shop_regex%/.*"
- provider: sylius_api_shop_user_provider
- stateless: true
- entry_point: jwt
- json_login:
- check_path: "%sylius.security.new_api_shop_route%/authentication-token"
- username_path: email
- password_path: password
- success_handler: lexik_jwt_authentication.handler.authentication_success
- failure_handler: lexik_jwt_authentication.handler.authentication_failure
- jwt: true
-
- shop:
- switch_user: { role: ROLE_ALLOWED_TO_SWITCH }
- context: shop
- pattern: "%sylius.security.shop_regex%"
- provider: sylius_shop_user_provider
- form_login:
- success_handler: sylius.authentication.success_handler
- failure_handler: sylius.authentication.failure_handler
- provider: sylius_shop_user_provider
- login_path: sylius_shop_login
- check_path: sylius_shop_login_check
- failure_path: sylius_shop_login
- default_target_path: sylius_shop_homepage
- use_forward: false
- use_referer: true
- enable_csrf: true
- csrf_parameter: _csrf_shop_security_token
- csrf_token_id: shop_authenticate
- remember_me:
- secret: "%env(APP_SECRET)%"
- name: APP_SHOP_REMEMBER_ME
- lifetime: 31536000
- remember_me_parameter: _remember_me
- logout:
- path: sylius_shop_logout
- target: sylius_shop_homepage
- invalidate_session: false
-
- dev:
- pattern: ^/(_(profiler|wdt)|css|images|js)/
- security: false
-
- image_resolver:
- pattern: ^/media/cache/resolve
- security: false
-
- access_control:
- - { path: "%sylius.security.admin_regex%/_partial", role: PUBLIC_ACCESS, ips: [127.0.0.1, ::1] }
- - { path: "%sylius.security.admin_regex%/_partial", role: ROLE_NO_ACCESS }
- - { path: "%sylius.security.shop_regex%/_partial", role: PUBLIC_ACCESS, ips: [127.0.0.1, ::1] }
- - { path: "%sylius.security.shop_regex%/_partial", role: ROLE_NO_ACCESS }
-
- - { path: "%sylius.security.admin_regex%/login", role: PUBLIC_ACCESS }
- - { path: "%sylius.security.shop_regex%/login", role: PUBLIC_ACCESS }
-
- - { path: "%sylius.security.shop_regex%/register", role: PUBLIC_ACCESS }
- - { path: "%sylius.security.shop_regex%/verify", role: PUBLIC_ACCESS }
-
- - { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS }
- - { path: "%sylius.security.shop_regex%/account", role: ROLE_USER }
-
- - { path: "%sylius.security.new_api_admin_route%/reset-password-requests", role: PUBLIC_ACCESS }
- - { path: "%sylius.security.new_api_admin_regex%/.*", role: ROLE_API_ACCESS }
- - { path: "%sylius.security.new_api_admin_route%/authentication-token", role: PUBLIC_ACCESS }
- - { path: "%sylius.security.new_api_user_account_regex%/.*", role: ROLE_USER }
- - { path: "%sylius.security.new_api_shop_route%/authentication-token", role: PUBLIC_ACCESS }
- - { path: "%sylius.security.new_api_shop_regex%/.*", role: PUBLIC_ACCESS }
diff --git a/tests/Application/config/sylius/1.14/bundles.php b/tests/Application/config/sylius/1.14/bundles.php
deleted file mode 100644
index e615f85b..00000000
--- a/tests/Application/config/sylius/1.14/bundles.php
+++ /dev/null
@@ -1,14 +0,0 @@
- ['all' => true],
-];
diff --git a/tests/Application/config/sylius/1.14/packages/_sylius.yaml b/tests/Application/config/sylius/1.14/packages/_sylius.yaml
deleted file mode 100644
index baa3d7ed..00000000
--- a/tests/Application/config/sylius/1.14/packages/_sylius.yaml
+++ /dev/null
@@ -1,10 +0,0 @@
-parameters:
- test_default_state_machine_adapter: 'symfony_workflow'
- test_sylius_state_machine_adapter: '%env(string:default:test_default_state_machine_adapter:TEST_SYLIUS_STATE_MACHINE_ADAPTER)%'
-
-sylius_state_machine_abstraction:
- graphs_to_adapters_mapping:
- sylius_refund_refund_payment: '%test_sylius_state_machine_adapter%'
-
-sylius_api:
- enabled: true
diff --git a/tests/Application/config/sylius/1.14/packages/security.yaml b/tests/Application/config/sylius/1.14/packages/security.yaml
deleted file mode 100644
index 4ed342f8..00000000
--- a/tests/Application/config/sylius/1.14/packages/security.yaml
+++ /dev/null
@@ -1,124 +0,0 @@
-security:
- enable_authenticator_manager: true
- providers:
- sylius_admin_user_provider:
- id: sylius.admin_user_provider.email_or_name_based
- sylius_api_admin_user_provider:
- id: sylius.admin_user_provider.email_or_name_based
- sylius_shop_user_provider:
- id: sylius.shop_user_provider.email_or_name_based
- sylius_api_shop_user_provider:
- id: sylius.shop_user_provider.email_or_name_based
-
- password_hashers:
- Sylius\Component\User\Model\UserInterface: argon2i
- firewalls:
- admin:
- switch_user: true
- context: admin
- pattern: "%sylius.security.admin_regex%"
- provider: sylius_admin_user_provider
- form_login:
- provider: sylius_admin_user_provider
- login_path: sylius_admin_login
- check_path: sylius_admin_login_check
- failure_path: sylius_admin_login
- default_target_path: sylius_admin_dashboard
- use_forward: false
- use_referer: true
- enable_csrf: true
- csrf_parameter: _csrf_admin_security_token
- csrf_token_id: admin_authenticate
- remember_me:
- secret: "%env(APP_SECRET)%"
- path: "/%sylius_admin.path_name%"
- name: APP_ADMIN_REMEMBER_ME
- lifetime: 31536000
- remember_me_parameter: _remember_me
- logout:
- path: sylius_admin_logout
- target: sylius_admin_login
-
- new_api_admin_user:
- pattern: "%sylius.security.new_api_admin_regex%/.*"
- provider: sylius_api_admin_user_provider
- stateless: true
- entry_point: jwt
- json_login:
- check_path: "%sylius.security.new_api_admin_route%/authentication-token"
- username_path: email
- password_path: password
- success_handler: lexik_jwt_authentication.handler.authentication_success
- failure_handler: lexik_jwt_authentication.handler.authentication_failure
- jwt: true
-
- new_api_shop_user:
- pattern: "%sylius.security.new_api_shop_regex%/.*"
- provider: sylius_api_shop_user_provider
- stateless: true
- entry_point: jwt
- json_login:
- check_path: "%sylius.security.new_api_shop_route%/authentication-token"
- username_path: email
- password_path: password
- success_handler: lexik_jwt_authentication.handler.authentication_success
- failure_handler: lexik_jwt_authentication.handler.authentication_failure
- jwt: true
-
- shop:
- switch_user: { role: ROLE_ALLOWED_TO_SWITCH }
- context: shop
- pattern: "%sylius.security.shop_regex%"
- provider: sylius_shop_user_provider
- form_login:
- success_handler: sylius.authentication.success_handler
- failure_handler: sylius.authentication.failure_handler
- provider: sylius_shop_user_provider
- login_path: sylius_shop_login
- check_path: sylius_shop_login_check
- failure_path: sylius_shop_login
- default_target_path: sylius_shop_homepage
- use_forward: false
- use_referer: true
- enable_csrf: true
- csrf_parameter: _csrf_shop_security_token
- csrf_token_id: shop_authenticate
- remember_me:
- secret: "%env(APP_SECRET)%"
- name: APP_SHOP_REMEMBER_ME
- lifetime: 31536000
- remember_me_parameter: _remember_me
- logout:
- path: sylius_shop_logout
- target: sylius_shop_homepage
- invalidate_session: false
-
- dev:
- pattern: ^/(_(profiler|wdt)|css|images|js)/
- security: false
-
- image_resolver:
- pattern: ^/media/cache/resolve
- security: false
-
- access_control:
- - { path: "%sylius.security.admin_regex%/_partial", role: PUBLIC_ACCESS, ips: [127.0.0.1, ::1] }
- - { path: "%sylius.security.admin_regex%/_partial", role: ROLE_NO_ACCESS }
- - { path: "%sylius.security.shop_regex%/_partial", role: PUBLIC_ACCESS, ips: [127.0.0.1, ::1] }
- - { path: "%sylius.security.shop_regex%/_partial", role: ROLE_NO_ACCESS }
-
- - { path: "%sylius.security.admin_regex%/login", role: PUBLIC_ACCESS }
- - { path: "%sylius.security.shop_regex%/login", role: PUBLIC_ACCESS }
-
- - { path: "%sylius.security.shop_regex%/register", role: PUBLIC_ACCESS }
- - { path: "%sylius.security.shop_regex%/verify", role: PUBLIC_ACCESS }
-
- - { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS }
- - { path: "%sylius.security.shop_regex%/account", role: ROLE_USER }
-
- - { path: "%sylius.security.new_api_admin_route%/reset-password-requests", role: PUBLIC_ACCESS }
- - { path: "%sylius.security.new_api_admin_regex%/.*", role: ROLE_API_ACCESS }
- - { path: "%sylius.security.new_api_admin_route%/authentication-token", role: PUBLIC_ACCESS }
- - { path: "%sylius.security.new_api_user_account_regex%/.*", role: ROLE_USER }
- - { path: "%sylius.security.new_api_shop_route%/authentication-token", role: PUBLIC_ACCESS }
- - { path: "%sylius.security.new_api_shop_regex%/.*", role: PUBLIC_ACCESS }
diff --git a/tests/Application/package.json b/tests/Application/package.json
index ac5c1436..55b1f3f7 100644
--- a/tests/Application/package.json
+++ b/tests/Application/package.json
@@ -1,46 +1,21 @@
{
- "dependencies": {
- "@babel/core": "^7.24.9",
- "@babel/preset-env": "^7.14.7",
- "babel-polyfill": "^6.26.0",
- "chart.js": "^3.9.1",
- "jquery": "^3.6.0",
- "jquery.dirtyforms": "^2.0.0",
- "lightbox2": "^2.11.0",
- "semantic-ui-css": "^2.4.0",
- "slick-carousel": "^1.8.1"
- },
- "devDependencies": {
- "@symfony/webpack-encore": "^4.0.0",
- "babel-core": "^6.26.3",
- "babel-plugin-external-helpers": "^6.22.0",
- "babel-plugin-module-resolver": "^3.2.0",
- "babel-plugin-transform-object-rest-spread": "^6.26.0",
- "babel-preset-env": "^1.7.0",
- "babel-register": "^6.26.0",
- "dedent": "^0.7.0",
- "eslint": "^8.22.0",
- "eslint-config-airbnb-base": "^15.0.0",
- "eslint-import-resolver-babel-module": "^5.3.0",
- "eslint-plugin-import": "^2.26.0",
- "fast-async": "^7.0.6",
- "merge-stream": "^2.0.0",
- "sass": "^1.77.8",
- "sass-loader": "^13.0.0",
- "upath": "^2.0.0",
- "webpack": "^5.93.0",
- "webpack-cli": "^5.1.4",
- "yargs": "^17.7.1"
- },
+ "license": "MIT",
"scripts": {
- "dev": "yarn encore dev",
- "watch": "yarn encore dev --watch",
- "prod": "yarn encore prod"
+ "build": "encore dev",
+ "build:prod": "encore production",
+ "watch": "encore dev --watch",
+ "postinstall": "cd ./node_modules/@symfony/ux-autocomplete && npm install && cd - && cd ./node_modules/@symfony/ux-live-component && npm install && cd -"
},
- "repository": {
- "type": "git",
- "url": "git+https://github.com/Sylius/Sylius.git"
+ "dependencies": {
+ "@sylius-ui/admin": "git+https://github.com/Sylius/SyliusAdminBundle.git#2.0",
+ "@sylius-ui/shop": "git+https://github.com/Sylius/SyliusShopBundle.git#2.0",
+ "@symfony/ux-autocomplete": "file:../../vendor/symfony/ux-autocomplete/assets",
+ "@symfony/ux-live-component": "file:../../vendor/symfony/ux-live-component/assets"
},
- "author": "Paweł Jędrzejewski",
- "license": "MIT"
+ "devDependencies": {
+ "@hotwired/stimulus": "^3.0.0",
+ "@symfony/stimulus-bridge": "^3.2.0",
+ "@symfony/webpack-encore": "^5.0.1",
+ "tom-select": "^2.2.2"
+ }
}
diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/Customer/_form.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/Customer/_form.html.twig
deleted file mode 100644
index f4e2d6b6..00000000
--- a/tests/Application/templates/bundles/SyliusAdminBundle/Customer/_form.html.twig
+++ /dev/null
@@ -1,43 +0,0 @@
-{{ form_errors(form) }}
-
-
-
-
-
- {{ form_row(form.firstName) }}
- {{ form_row(form.lastName) }}
-
- {{ form_row(form.email) }}
- {{ form_row(form.group) }}
-
-
-
- {{ form_row(form.gender) }}
- {{ form_row(form.birthday) }}
- {{ form_row(form.phoneNumber) }}
- {{ form_row(form.subscribedToNewsletter) }}
-
-
-
-
-
- {% if customer.user is empty or customer.user.id is null %}
-
-
- {{ form_row(form.createUser) }}
-
-
- {% endif %}
- {% if form.user is defined %}
-
- {{ form_row(form.user.plainPassword) }}
- {{ form_row(form.user.enabled) }}
-
- {% endif %}
-
-
-
- {{ form_row(form.fraudStatus) }}
-
-
-
diff --git a/tests/Application/webpack.config.js b/tests/Application/webpack.config.js
index 4ca25fdd..e6ae6921 100644
--- a/tests/Application/webpack.config.js
+++ b/tests/Application/webpack.config.js
@@ -11,6 +11,7 @@ Encore
.setOutputPath('public/build/shop/')
.setPublicPath('/build/shop')
.addEntry('shop-entry', './assets/shop/entry.js')
+ .enableStimulusBridge('./assets/controllers.json')
.disableSingleRuntimeChunk()
.cleanupOutputBeforeBuild()
.enableSourceMaps(!Encore.isProduction())
@@ -31,6 +32,8 @@ Encore
.setOutputPath('public/build/admin/')
.setPublicPath('/build/admin')
.addEntry('admin-entry', './assets/admin/entry.js')
+ .addEntry('admin-product-entry', './assets/admin/product-entry.js')
+ .enableStimulusBridge('./assets/controllers.json')
.disableSingleRuntimeChunk()
.cleanupOutputBeforeBuild()
.enableSourceMaps(!Encore.isProduction())
diff --git a/tests/Behat/Behaviour/ContainsEmptyListTrait.php b/tests/Behat/Behaviour/ContainsEmptyListTrait.php
index d7f2e2fa..180b5790 100755
--- a/tests/Behat/Behaviour/ContainsEmptyListTrait.php
+++ b/tests/Behat/Behaviour/ContainsEmptyListTrait.php
@@ -17,6 +17,6 @@ trait ContainsEmptyListTrait
public function isEmpty(): bool
{
- return false !== strpos($this->getDocument()->find('css', '.message')->getText(), 'There are no results to display');
+ return false !== strpos($this->getDocument()->find('css', '.empty-title')->getText(), 'No results found');
}
}
diff --git a/tests/Behat/Behaviour/ContainsErrorTrait.php b/tests/Behat/Behaviour/ContainsErrorTrait.php
index 113180fa..5c35f710 100755
--- a/tests/Behat/Behaviour/ContainsErrorTrait.php
+++ b/tests/Behat/Behaviour/ContainsErrorTrait.php
@@ -18,7 +18,7 @@ trait ContainsErrorTrait
public function containsErrorWithMessage(string $message, bool $strict = true): bool
{
- $validationMessageElements = $this->getDocument()->findAll('css', '.sylius-validation-error');
+ $validationMessageElements = $this->getDocument()->findAll('css', '.invalid-feedback');
$result = false;
/** @var NodeElement $validationMessageElement */
diff --git a/tests/Behat/Page/Admin/AutomaticBlacklistingConfiguration/CreatePage.php b/tests/Behat/Page/Admin/AutomaticBlacklistingConfiguration/CreatePage.php
index 5ee52c06..70f940d8 100755
--- a/tests/Behat/Page/Admin/AutomaticBlacklistingConfiguration/CreatePage.php
+++ b/tests/Behat/Page/Admin/AutomaticBlacklistingConfiguration/CreatePage.php
@@ -36,13 +36,12 @@ public function selectOption(string $field, string $value): void
public function addRule(string $ruleName): void
{
- $count = count($this->getCollectionItems('rules'));
+ $this->getElement($ruleName)->press();
- $this->getDocument()->clickLink('Add rule');
+ $form = $this->getElement('form');
- $this->getSession()->wait(100);
-
- $this->selectRuleOption('Type', $ruleName);
+ usleep(1000000); // we need to sleep, as sometimes the check below is executed faster than the form sets the busy attribute
+ $form->waitFor(1500, fn () => !$form->hasAttribute('busy'));
}
public function selectRuleOption(string $option, string $value, bool $multiple = false): void
@@ -55,6 +54,27 @@ public function fillRuleOption(string $option, string $value): void
$this->getLastCollectionItem('rules')->fillField($option, $value);
}
+ public function fillRuleOption2(string $optionName, string $value): void
+ {
+ $field = $this->getDocument()->findField($optionName);
+ if (null === $field) {
+ throw new \InvalidArgumentException(sprintf('Field "%s" not found.', $optionName));
+ }
+ $field->setValue($value);
+ }
+
+ public function selectRuleOption2(string $optionName, string $value): void
+ {
+ $field = $this->getDocument()->findField($optionName);
+
+ if (null === $field) {
+ throw new \InvalidArgumentException(sprintf('Field "%s" not found.', $optionName));
+ }
+ $field->selectOption($value);
+ }
+
+
+
public function selectAutocompleteRuleOption(string $option, $value, bool $multiple = false): void
{
$option = strtolower(str_replace(' ', '_', $option));
@@ -93,6 +113,9 @@ protected function getDefinedElements(): array
{
return [
'rules' => '#bitbag_sylius_blacklist_plugin_automatic_blacklisting_configuration_rules',
+ 'Max number of orders' => '[data-test-add-orders]',
+ 'Max number of payment failures' => '[data-test-add-payment_failures]',
+ 'form' => 'form',
];
}
@@ -110,8 +133,7 @@ private function getLastCollectionItem(string $collection): NodeElement
*/
private function getCollectionItems(string $collection): array
{
- $items = $this->getElement($collection)->findAll('css', 'div[data-form-collection="item"]');
-
+ $items = $this->getElement($collection)->findAll('css', '[data-test-entry-row]');
Assert::isArray($items);
return $items;
diff --git a/tests/Behat/Page/Admin/AutomaticBlacklistingConfiguration/UpdatePage.php b/tests/Behat/Page/Admin/AutomaticBlacklistingConfiguration/UpdatePage.php
index c0b5b4c1..7c75ad49 100755
--- a/tests/Behat/Page/Admin/AutomaticBlacklistingConfiguration/UpdatePage.php
+++ b/tests/Behat/Page/Admin/AutomaticBlacklistingConfiguration/UpdatePage.php
@@ -35,7 +35,7 @@ public function uncheckField(string $locator): void
public function update(): void
{
- $this->getDocument()->pressButton('Save changes');
+ $this->getDocument()->pressButton('Update');
}
public function fillRuleOption(string $option, string $value): void
@@ -64,7 +64,7 @@ private function getLastCollectionItem(string $collection): NodeElement
*/
private function getCollectionItems(string $collection): array
{
- $items = $this->getElement($collection)->findAll('css', 'div[data-form-collection="item"]');
+ $items = $this->getElement($collection)->findAll('css', '[data-test-entry-row]');
Assert::isArray($items);
diff --git a/tests/Behat/Page/Admin/Customer/UpdatePage.php b/tests/Behat/Page/Admin/Customer/UpdatePage.php
index 9803a76c..2b219df4 100755
--- a/tests/Behat/Page/Admin/Customer/UpdatePage.php
+++ b/tests/Behat/Page/Admin/Customer/UpdatePage.php
@@ -20,6 +20,6 @@ public function selectOption(string $field, string $value): void
public function submit(): void
{
- $this->getDocument()->pressButton('Save changes');
+ $this->getDocument()->pressButton('Update');
}
}
diff --git a/tests/Behat/Page/Admin/FraudSuspicion/CreatePage.php b/tests/Behat/Page/Admin/FraudSuspicion/CreatePage.php
index 80e8a4e3..616d05e4 100755
--- a/tests/Behat/Page/Admin/FraudSuspicion/CreatePage.php
+++ b/tests/Behat/Page/Admin/FraudSuspicion/CreatePage.php
@@ -10,13 +10,26 @@
namespace Tests\BitBag\SyliusBlacklistPlugin\Behat\Page\Admin\FraudSuspicion;
use Behat\Mink\Element\DocumentElement;
+use Behat\Mink\Session;
use Sylius\Behat\Page\Admin\Crud\CreatePage as BaseCreatePage;
+use Sylius\Behat\Service\Helper\AutocompleteHelperInterface;
+use Symfony\Component\Routing\RouterInterface;
use Tests\BitBag\SyliusBlacklistPlugin\Behat\Behaviour\ContainsErrorTrait;
class CreatePage extends BaseCreatePage implements CreatePageInterface
{
use ContainsErrorTrait;
+ public function __construct(
+ Session $session,
+ $minkParameters,
+ RouterInterface $router,
+ string $routeName,
+ private AutocompleteHelperInterface $autocompleteHelper,
+ ) {
+ parent::__construct($session, $minkParameters, $router, $routeName);
+ }
+
public function fillField(string $field, ?string $value): CreatePageInterface
{
if (empty($value)) {
@@ -37,20 +50,9 @@ public function selectOption(string $field, string $value): CreatePageInterface
public function selectCustomer(string $customerEmail): CreatePageInterface
{
- $dropdown = $this->getElement('customer_dropdown');
- $dropdown->click();
-
- $dropdown->waitFor(5, function () use ($customerEmail) {
- return $this->hasElement('customer_dropdown_item', [
- '%item%' => $customerEmail,
- ]);
- });
-
- $item = $this->getElement('customer_dropdown_item', [
- '%item%' => $customerEmail,
- ]);
+ $productOptionsAutocomplete = $this->getElement('customer_dropdown');
- $item->click();
+ $this->autocompleteHelper->selectByName($this->getDriver(), $productOptionsAutocomplete->getXpath(), $customerEmail);
return $this;
}
@@ -58,8 +60,7 @@ public function selectCustomer(string $customerEmail): CreatePageInterface
protected function getDefinedElements(): array
{
return array_merge(parent::getDefinedElements(), [
- 'customer_dropdown' => '.field > label:contains("Customer") ~ .sylius-autocomplete',
- 'customer_dropdown_item' => '.field > label:contains("Customer") ~ .sylius-autocomplete > div.menu > div.item:contains("%item%")',
+ 'customer_dropdown' => '[data-test-fraud-suspicion-customer-autocomplete]',
]);
}
}
diff --git a/tests/Behat/Resources/services/contexts/ui.xml b/tests/Behat/Resources/services/contexts/ui.xml
index f02eb9a9..fa43c224 100644
--- a/tests/Behat/Resources/services/contexts/ui.xml
+++ b/tests/Behat/Resources/services/contexts/ui.xml
@@ -12,7 +12,7 @@
class="Tests\BitBag\SyliusBlacklistPlugin\Behat\Context\Ui\Admin\BlacklistingRuleContext">
-
+
@@ -24,7 +24,7 @@
class="Tests\BitBag\SyliusBlacklistPlugin\Behat\Context\Ui\Admin\CustomerContext">
-
+
@@ -36,7 +36,7 @@
class="Tests\BitBag\SyliusBlacklistPlugin\Behat\Context\Ui\Admin\FraudSuspicionContext">
-
+
@@ -51,7 +51,7 @@
class="Tests\BitBag\SyliusBlacklistPlugin\Behat\Context\Ui\Admin\AutomaticBlacklistingConfigurationContext">
-
+
diff --git a/tests/Behat/Resources/services/pages/admin/fraud_suspicion.xml b/tests/Behat/Resources/services/pages/admin/fraud_suspicion.xml
index a3709709..88c9ac99 100644
--- a/tests/Behat/Resources/services/pages/admin/fraud_suspicion.xml
+++ b/tests/Behat/Resources/services/pages/admin/fraud_suspicion.xml
@@ -10,6 +10,7 @@
bitbag_sylius_blacklist_plugin_admin_fraud_suspicion_create
+
bitbag_sylius_blacklist_plugin_admin_order_mark_suspicious
-
\ No newline at end of file
+
diff --git a/src/Resources/translations/messages.en.yml b/translations/messages.en.yml
similarity index 94%
rename from src/Resources/translations/messages.en.yml
rename to translations/messages.en.yml
index b09f055b..f75121fe 100644
--- a/src/Resources/translations/messages.en.yml
+++ b/translations/messages.en.yml
@@ -1,7 +1,9 @@
bitbag_sylius_blacklist_plugin:
ui:
blacklisting_rules: Blacklisting rules
+ blacklisting_rule: Blacklisting rule
fraud_suspicions: Fraud suspicions
+ fraud_suspicion: Fraud suspicion
manage_blacklisting_rules: Manage blacklisting rules
manage_fraud_suspicions: Manage fraud suspicions
edit_fraud_suspicion: Edit fraud suspicion
@@ -18,6 +20,7 @@ bitbag_sylius_blacklist_plugin:
mark_suspicious: Mark suspicious
mark_blacklisted: Mark blacklisted
mark_neutral: Mark neutral
+ automatic_blacklisting_configuration: Auto-block rules
automatic_blacklisting_configurations: Auto-block rules
configure_automatic_blacklisting_configurations: Configure auto-blacklisitng
new_automatic_blacklisting_configuration: Add new automatic blacklisting configuration
@@ -71,4 +74,4 @@ bitbag_sylius_blacklist_plugin:
date_modifier: Date modifier
per_day: Per day
per_week: Per week
- per_month: Per month
\ No newline at end of file
+ per_month: Per month
diff --git a/src/Resources/translations/validators.en.yml b/translations/validators.en.yml
similarity index 100%
rename from src/Resources/translations/validators.en.yml
rename to translations/validators.en.yml
diff --git a/webpack.config.js b/webpack.config.js
index 94a3bc00..fcb163dc 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -8,7 +8,7 @@ const getConfig = (pluginName, type) => {
Encore
.setOutputPath(`public/build/bitbag/${pluginName}/${type}/`)
.setPublicPath(`/build/bitbag/${pluginName}/${type}/`)
- .addEntry(`bitbag-${pluginName}-${type}`, path.resolve(__dirname, `./src/Resources/assets/${type}/entry.js`))
+ .addEntry(`bitbag-${pluginName}-${type}`, path.resolve(__dirname, `./assets/${type}/entry.js`))
.disableSingleRuntimeChunk()
.cleanupOutputBeforeBuild()
.enableSourceMaps(!Encore.isProduction())
@@ -23,8 +23,8 @@ const getConfig = (pluginName, type) => {
Encore
.setOutputPath(`src/Resources/public/`)
.setPublicPath(`/public/`)
- .addEntry(`bitbag-${pluginName}-shop`, path.resolve(__dirname, `./src/Resources/assets/shop/entry.js`))
- .addEntry(`bitbag-${pluginName}-admin`, path.resolve(__dirname, `./src/Resources/assets/admin/entry.js`))
+ .addEntry(`bitbag-${pluginName}-shop`, path.resolve(__dirname, `./assets/shop/entry.js`))
+ .addEntry(`bitbag-${pluginName}-admin`, path.resolve(__dirname, `./assets/admin/entry.js`))
.cleanupOutputBeforeBuild()
.disableSingleRuntimeChunk()
.enableSassLoader();