From 1316a86b4180f8c433b18e8c6fbc9e575b88f9b7 Mon Sep 17 00:00:00 2001
From: jb cr <51637606+jbcr@users.noreply.github.com>
Date: Wed, 18 Dec 2024 15:02:57 +0100
Subject: [PATCH 01/17] Allow Sylius 2.0
---
composer.json | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/composer.json b/composer.json
index 0fe013e..e5bedd6 100644
--- a/composer.json
+++ b/composer.json
@@ -14,8 +14,8 @@
"php": "^8.2",
"php-http/message-factory": "^1.1",
"phpdocumentor/reflection-docblock": "^5.3",
- "sylius/sylius": "^1.12",
- "symfony/property-info": "^6.4"
+ "sylius/sylius": "^2.0",
+ "symfony/property-info": "^6.4|^7.0"
},
"require-dev": {
"j13k/yaml-lint": "^1.1",
From 417d1b2d9527c0733339b3013e31d2d76d428e4f Mon Sep 17 00:00:00 2001
From: jb cr <51637606+jbcr@users.noreply.github.com>
Date: Wed, 18 Dec 2024 15:18:17 +0100
Subject: [PATCH 02/17] update composer.json to install with Sylius 2.0
---
.github/workflows/sylius.yaml | 5 ++---
composer.json | 3 ++-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/.github/workflows/sylius.yaml b/.github/workflows/sylius.yaml
index 745e4d7..87626ba 100644
--- a/.github/workflows/sylius.yaml
+++ b/.github/workflows/sylius.yaml
@@ -19,13 +19,12 @@ jobs:
- 8.2
- 8.3
sylius:
- - 1.12.0
- - 1.13.0
- 1.14.0
+ - 2.0.0
symfony:
- 6.4
node:
- - 14.x
+ - 20.x
env:
APP_ENV: test
package-name: synolia/sylius-gdpr-plugin
diff --git a/composer.json b/composer.json
index e5bedd6..702fb58 100644
--- a/composer.json
+++ b/composer.json
@@ -45,7 +45,8 @@
"dealerdirect/phpcodesniffer-composer-installer": true,
"symfony/thanks": true,
"phpro/grumphp": true,
- "phpstan/extension-installer": true
+ "phpstan/extension-installer": true,
+ "php-http/discovery": true
}
},
"autoload": {
From 48cd8b0ab94df4450390364d4aa4226566ed5cb6 Mon Sep 17 00:00:00 2001
From: jb cr <51637606+jbcr@users.noreply.github.com>
Date: Wed, 18 Dec 2024 15:21:15 +0100
Subject: [PATCH 03/17] add branch name to test
---
.github/workflows/sylius.yaml | 1 +
1 file changed, 1 insertion(+)
diff --git a/.github/workflows/sylius.yaml b/.github/workflows/sylius.yaml
index 87626ba..b7c7399 100644
--- a/.github/workflows/sylius.yaml
+++ b/.github/workflows/sylius.yaml
@@ -3,6 +3,7 @@ name: Install & Test
push:
branches:
- main
+ - upgrade_sylius_2.0
paths-ignore:
- README.md
pull_request:
From 0cef399e9d15074fc406091c8d42099be7c5e93a Mon Sep 17 00:00:00 2001
From: jb cr <51637606+jbcr@users.noreply.github.com>
Date: Wed, 18 Dec 2024 15:23:36 +0100
Subject: [PATCH 04/17] exclude Sylius 2.0 and Symfony 5.4 + upgrade task
version
---
.github/workflows/sylius.yaml | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/sylius.yaml b/.github/workflows/sylius.yaml
index b7c7399..e5c6394 100644
--- a/.github/workflows/sylius.yaml
+++ b/.github/workflows/sylius.yaml
@@ -26,6 +26,10 @@ jobs:
- 6.4
node:
- 20.x
+ exclude:
+ -
+ sylius: 2.0.0
+ symfony: 5.4
env:
APP_ENV: test
package-name: synolia/sylius-gdpr-plugin
@@ -45,14 +49,14 @@ jobs:
with:
node-version: '${{ matrix.node }}'
-
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
-
name: 'Composer - Get Cache Directory'
id: composer-cache
run: 'echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT'
-
name: 'Composer - Set cache'
- uses: actions/cache@v3
+ uses: actions/cache@v4
id: cache-composer
with:
path: '${{ steps.composer-cache.outputs.dir }}'
@@ -71,7 +75,7 @@ jobs:
run: 'echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT'
-
name: 'Yarn - Set Cache'
- uses: actions/cache@v3
+ uses: actions/cache@v4
with:
path: '${{ steps.yarn-cache.outputs.dir }}'
key: 'node-${{ matrix.node }}-yarn-${{ hashFiles(''**/package.json **/yarn.lock'') }}'
From fa56ea0ef095e2c5cfaa739bc0f9069e9d208cb7 Mon Sep 17 00:00:00 2001
From: jb cr <51637606+jbcr@users.noreply.github.com>
Date: Wed, 18 Dec 2024 16:36:29 +0100
Subject: [PATCH 05/17] update to install with Sylius 2.0
---
Makefile | 4 ++++
src/Resources/config/mappings/ShopUser.yaml | 10 +++++-----
src/Resources/config/packages/twig_hooks.yaml | 8 ++++++++
src/Resources/config/packages/ui.yaml | 11 ++++++-----
4 files changed, 23 insertions(+), 10 deletions(-)
create mode 100644 src/Resources/config/packages/twig_hooks.yaml
diff --git a/Makefile b/Makefile
index 5af0ba5..b4091de 100644
--- a/Makefile
+++ b/Makefile
@@ -44,6 +44,10 @@ sylius-standard:
update-dependencies:
${COMPOSER} config extra.symfony.require "~${SYMFONY_VERSION}"
${COMPOSER} require symfony/asset:~${SYMFONY_VERSION} --no-scripts --no-update
+ifeq ($(SYLIUS_VERSION)$(SYMFONY_VERSION), 2.0.06.4)
+ ${COMPOSER} update --no-progress -n --no-scripts
+ rm ${TEST_DIRECTORY}/config/packages/csrf.yaml
+endif
${COMPOSER} update --no-progress -n
install-plugin:
diff --git a/src/Resources/config/mappings/ShopUser.yaml b/src/Resources/config/mappings/ShopUser.yaml
index f82b4db..71ac9fe 100644
--- a/src/Resources/config/mappings/ShopUser.yaml
+++ b/src/Resources/config/mappings/ShopUser.yaml
@@ -22,11 +22,11 @@ Sylius\Component\Core\Model\ShopUser:
faker: dateTime
verifiedAt:
faker: dateTime
- locked:
- faker: boolean
- args: [100]
- credentialsExpireAt:
- faker: dateTime
+# locked:
+# faker: boolean
+# args: [100]
+# credentialsExpireAt:
+# faker: dateTime
email:
faker: email
unique: true
diff --git a/src/Resources/config/packages/twig_hooks.yaml b/src/Resources/config/packages/twig_hooks.yaml
new file mode 100644
index 0000000..8fbb972
--- /dev/null
+++ b/src/Resources/config/packages/twig_hooks.yaml
@@ -0,0 +1,8 @@
+#sylius_twig_hooks:
+# hooks:
+# sylius_admin.customer.show.information:
+
+
+# sylius.admin.customer.show.information:
+# blocks:
+# gdpr: '@SynoliaSyliusGDPRPlugin\Admin\Customer\Show\gdpr.html.twig'
diff --git a/src/Resources/config/packages/ui.yaml b/src/Resources/config/packages/ui.yaml
index 31c46c2..bfbb4f9 100644
--- a/src/Resources/config/packages/ui.yaml
+++ b/src/Resources/config/packages/ui.yaml
@@ -1,5 +1,6 @@
-sylius_ui:
- events:
- sylius.admin.customer.show.information:
- blocks:
- gdpr: '@SynoliaSyliusGDPRPlugin\Admin\Customer\Show\gdpr.html.twig'
+#sylius_ui:
+# events:
+# sylius.admin.customer.show.information:
+# blocks:
+# gdpr: '@SynoliaSyliusGDPRPlugin\Admin\Customer\Show\gdpr.html.twig'
+#
From cb69ba961ab19338de886754a5d9fcfafc95303e Mon Sep 17 00:00:00 2001
From: jb cr <51637606+jbcr@users.noreply.github.com>
Date: Tue, 11 Mar 2025 09:49:31 +0100
Subject: [PATCH 06/17] try change product
---
compose.yaml | 12 ++++++++++++
.../PHPUnit/Controller/ExportDataControllerTest.php | 5 +++--
2 files changed, 15 insertions(+), 2 deletions(-)
create mode 100644 compose.yaml
diff --git a/compose.yaml b/compose.yaml
new file mode 100644
index 0000000..2f21342
--- /dev/null
+++ b/compose.yaml
@@ -0,0 +1,12 @@
+services:
+ mariadb:
+ image: 'mariadb:10.5'
+ ports:
+ - '3306:3306'
+ volumes:
+ - gdpr_mysql:/var/lib/data
+ environment:
+ MYSQL_ALLOW_EMPTY_PASSWORD: true
+# options: '--health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3'
+volumes:
+ gdpr_mysql: ~
diff --git a/tests/PHPUnit/Controller/ExportDataControllerTest.php b/tests/PHPUnit/Controller/ExportDataControllerTest.php
index 35fd207..8da7280 100644
--- a/tests/PHPUnit/Controller/ExportDataControllerTest.php
+++ b/tests/PHPUnit/Controller/ExportDataControllerTest.php
@@ -22,12 +22,13 @@ public function testExportDataWithCart(): void
$client->loginUser($shopUser);
// go to product page
- $client->request('GET', '/en_US/products/sport-basic-white-t-shirt');
- $this->assertSelectorTextContains('h1', 'Sport basic white T-Shirt');
+ $client->request('GET', '/en_US/products/solar-echo-t-shirt');
+ $this->assertSelectorTextContains('h1', 'Solar Echo T-Shirt');
// add product to cart
$client->submitForm('Add to cart');
$client->request('GET', '/en_US/cart/');
+
$this->assertSelectorTextContains('h1', 'Your shopping cart');
// login as admin and go to customer page
From 834bde8e7648c72e20d0a5bc30ac49bb03165a41 Mon Sep 17 00:00:00 2001
From: jb cr <51637606+jbcr@users.noreply.github.com>
Date: Tue, 11 Mar 2025 09:52:22 +0100
Subject: [PATCH 07/17] remove file if exist
---
Makefile | 2 +-
tests/PHPUnit/Controller/ExportDataControllerTest.php | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index b4091de..e22396d 100644
--- a/Makefile
+++ b/Makefile
@@ -46,7 +46,7 @@ update-dependencies:
${COMPOSER} require symfony/asset:~${SYMFONY_VERSION} --no-scripts --no-update
ifeq ($(SYLIUS_VERSION)$(SYMFONY_VERSION), 2.0.06.4)
${COMPOSER} update --no-progress -n --no-scripts
- rm ${TEST_DIRECTORY}/config/packages/csrf.yaml
+ test -f ${TEST_DIRECTORY}/config/packages/csrf.yaml && rm ${TEST_DIRECTORY}/config/packages/csrf.yaml || true
endif
${COMPOSER} update --no-progress -n
diff --git a/tests/PHPUnit/Controller/ExportDataControllerTest.php b/tests/PHPUnit/Controller/ExportDataControllerTest.php
index 8da7280..72457a7 100644
--- a/tests/PHPUnit/Controller/ExportDataControllerTest.php
+++ b/tests/PHPUnit/Controller/ExportDataControllerTest.php
@@ -23,6 +23,7 @@ public function testExportDataWithCart(): void
// go to product page
$client->request('GET', '/en_US/products/solar-echo-t-shirt');
+ dump($client->getCrawler()->filter('h1')->text());
$this->assertSelectorTextContains('h1', 'Solar Echo T-Shirt');
// add product to cart
From 4c3a093ae574bb9821e7ce4aa79a3741eb408987 Mon Sep 17 00:00:00 2001
From: jb cr <51637606+jbcr@users.noreply.github.com>
Date: Tue, 11 Mar 2025 16:33:49 +0100
Subject: [PATCH 08/17] :arrow_up: Upgrade to Symfony 6.4 and 7.0+ and Sylius
2.0
---
src/{Annotation => Attribute}/Anonymize.php | 20 +++----
.../AnonymizeCustomersNotLoggedBeforeType.php | 4 +-
...izeCustomersWithoutAnyOrdersBeforeType.php | 4 +-
...notationLoader.php => AttributeLoader.php} | 25 ++++-----
src/Menu/AdminMenuListener.php | 2 +
src/Resources/config/app/config.yaml | 2 +-
src/Resources/config/packages/twig_hooks.yaml | 52 ++++++++++++++++---
src/Resources/config/packages/ui.yaml | 6 ---
.../views/Admin/Customer/Show/gdpr.html.twig | 30 ++++++-----
src/Resources/views/Admin/layout.html.twig | 16 ------
src/Resources/views/Gdpr/Actions.html.twig | 29 ++---------
.../views/Gdpr/part/footer.html.twig | 9 ++++
src/Resources/views/Gdpr/part/form.html.twig | 15 ++++++
src/Twig/GdprExtension.php | 2 +-
.../Controller/ExportDataControllerTest.php | 2 +-
tests/PHPUnit/Fixtures/Foo.php | 2 +-
16 files changed, 121 insertions(+), 99 deletions(-)
rename src/{Annotation => Attribute}/Anonymize.php (62%)
rename src/Loader/{AnnotationLoader.php => AttributeLoader.php} (54%)
delete mode 100644 src/Resources/config/packages/ui.yaml
delete mode 100644 src/Resources/views/Admin/layout.html.twig
create mode 100644 src/Resources/views/Gdpr/part/footer.html.twig
create mode 100644 src/Resources/views/Gdpr/part/form.html.twig
diff --git a/src/Annotation/Anonymize.php b/src/Attribute/Anonymize.php
similarity index 62%
rename from src/Annotation/Anonymize.php
rename to src/Attribute/Anonymize.php
index ffefa31..a2023d1 100644
--- a/src/Annotation/Anonymize.php
+++ b/src/Attribute/Anonymize.php
@@ -2,29 +2,23 @@
declare(strict_types=1);
-namespace Synolia\SyliusGDPRPlugin\Annotation;
+namespace Synolia\SyliusGDPRPlugin\Attribute;
use Doctrine\ORM\Mapping\MappingAttribute;
use Synolia\SyliusGDPRPlugin\Validator\FakerOptionsValidator;
-/**
- * @Annotation
- *
- * @Target({"PROPERTY","ANNOTATION"})
- */
+#[\Attribute(\Attribute::TARGET_PROPERTY)]
final class Anonymize implements MappingAttribute
{
- public ?string $faker;
+ public readonly ?string $faker;
- public array $args = [];
+ public readonly array $args;
- public bool $unique = false;
+ public readonly bool $unique;
- /** @var string|int|null */
- public $prefix = '';
+ public readonly string|int|null $prefix;
- /** @var string|int|array|bool|null */
- public $value;
+ public readonly string|int|array|bool|null $value;
public function __construct(array $options = [])
{
diff --git a/src/Form/Type/Actions/AnonymizeCustomersNotLoggedBeforeType.php b/src/Form/Type/Actions/AnonymizeCustomersNotLoggedBeforeType.php
index f7857f4..bb6cfaf 100644
--- a/src/Form/Type/Actions/AnonymizeCustomersNotLoggedBeforeType.php
+++ b/src/Form/Type/Actions/AnonymizeCustomersNotLoggedBeforeType.php
@@ -19,11 +19,11 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
->add('anonymize_customers_not_logged_before_date', DateType::class, [
'label' => false,
'widget' => 'single_text',
- 'row_attr' => ['class' => 'ui field'],
+ 'row_attr' => ['class' => ''],
])
->add('anonymize_customers_not_logged_submit', SubmitType::class, [
'label' => 'sylius.ui.execute',
- 'attr' => ['class' => 'ui blue button'],
+ 'attr' => ['class' => 'btn btn-warning mb-3'],
])
;
}
diff --git a/src/Form/Type/Actions/AnonymizeCustomersWithoutAnyOrdersBeforeType.php b/src/Form/Type/Actions/AnonymizeCustomersWithoutAnyOrdersBeforeType.php
index 6a77da4..3301736 100644
--- a/src/Form/Type/Actions/AnonymizeCustomersWithoutAnyOrdersBeforeType.php
+++ b/src/Form/Type/Actions/AnonymizeCustomersWithoutAnyOrdersBeforeType.php
@@ -19,11 +19,11 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
->add('anonymize_customer_without_any_orders_before_date', DateType::class, [
'label' => false,
'widget' => 'single_text',
- 'row_attr' => ['class' => 'ui field'],
+ 'row_attr' => ['class' => ''],
])
->add('anonymize_customer_without_any_orders_submit', SubmitType::class, [
'label' => 'sylius.ui.execute',
- 'attr' => ['class' => 'ui blue button'],
+ 'attr' => ['class' => 'btn btn-warning mb-3'],
])
;
}
diff --git a/src/Loader/AnnotationLoader.php b/src/Loader/AttributeLoader.php
similarity index 54%
rename from src/Loader/AnnotationLoader.php
rename to src/Loader/AttributeLoader.php
index 862e040..11378f0 100644
--- a/src/Loader/AnnotationLoader.php
+++ b/src/Loader/AttributeLoader.php
@@ -4,18 +4,13 @@
namespace Synolia\SyliusGDPRPlugin\Loader;
-use Doctrine\Common\Annotations\Reader;
use Doctrine\Common\Util\ClassUtils;
-use Synolia\SyliusGDPRPlugin\Annotation\Anonymize;
+use Synolia\SyliusGDPRPlugin\Attribute\Anonymize;
use Synolia\SyliusGDPRPlugin\Loader\Mapping\AttributeMetaData;
use Synolia\SyliusGDPRPlugin\Loader\Mapping\AttributeMetadataCollection;
-final readonly class AnnotationLoader implements LoaderInterface
+final readonly class AttributeLoader implements LoaderInterface
{
- public function __construct(private Reader $annotationReader)
- {
- }
-
/** @throws \ReflectionException */
public function loadClassMetadata(string $className): AttributeMetadataCollection
{
@@ -23,16 +18,18 @@ public function loadClassMetadata(string $className): AttributeMetadataCollectio
$properties = $reflectionClass->getProperties();
$attributeMetaDataCollection = new AttributeMetadataCollection();
foreach ($properties as $property) {
- $annotation = $this->annotationReader->getPropertyAnnotation(
- $property,
- Anonymize::class,
- );
+ $attributes = $property->getAttributes(Anonymize::class, \ReflectionAttribute::IS_INSTANCEOF);
- if (!$annotation instanceof Anonymize) {
+ if (\count($attributes) === 0) {
continue;
}
-
- $attributeMetaData = new AttributeMetaData($annotation->faker, $annotation->args, $annotation->unique, $annotation->prefix, $annotation->value);
+ $attributesInstances = [];
+ foreach ($attributes as $attribute) {
+ $attributesInstances[] = $attribute->newInstance();
+ }
+ /** @var Anonymize $attribute */
+ $attribute = $attributesInstances[0];
+ $attributeMetaData = new AttributeMetaData($attribute->faker, $attribute->args, $attribute->unique, $attribute->prefix, $attribute->value);
$attributeMetaDataCollection->add($property->name, $attributeMetaData);
}
diff --git a/src/Menu/AdminMenuListener.php b/src/Menu/AdminMenuListener.php
index 9a592ea..b048fc5 100644
--- a/src/Menu/AdminMenuListener.php
+++ b/src/Menu/AdminMenuListener.php
@@ -15,6 +15,8 @@ public function addAdminMenuItems(MenuBuilderEvent $event): void
$menu = $event->getMenu();
$gdprMenu = $menu->addChild('gdpr');
+ $gdprMenu->setLabel('sylius.ui.admin.synolia_gdpr.customer.gdpr_title');
+ $gdprMenu->setLabelAttribute('icon', 'tabler:database-star');
$gdprMenu
->addChild('sylius.ui.admin.synolia_gdpr.advanced_actions.title', [
'route' => 'synolia_sylius_gdpr_admin_advanced_actions',
diff --git a/src/Resources/config/app/config.yaml b/src/Resources/config/app/config.yaml
index fe12115..7474a45 100644
--- a/src/Resources/config/app/config.yaml
+++ b/src/Resources/config/app/config.yaml
@@ -1,2 +1,2 @@
imports:
- - { resource: "@SynoliaSyliusGDPRPlugin/Resources/config/packages/ui.yaml" }
\ No newline at end of file
+ - { resource: "@SynoliaSyliusGDPRPlugin/Resources/config/packages/twig_hooks.yaml" }
diff --git a/src/Resources/config/packages/twig_hooks.yaml b/src/Resources/config/packages/twig_hooks.yaml
index 8fbb972..f1cbfd4 100644
--- a/src/Resources/config/packages/twig_hooks.yaml
+++ b/src/Resources/config/packages/twig_hooks.yaml
@@ -1,8 +1,48 @@
-#sylius_twig_hooks:
-# hooks:
-# sylius_admin.customer.show.information:
+sylius_twig_hooks:
+ hooks:
+ 'sylius_admin.customer.show.content.sections':
+ gdpr:
+ template: '@SynoliaSyliusGDPRPlugin/Admin/Customer/Show/gdpr.html.twig'
+ priority: -100
+ 'sylius_admin.synolia_gdpr_plugin.index':
+ sidebar:
+ template: '@SyliusAdmin/shared/crud/common/sidebar.html.twig'
+ priority: 200
+ navbar:
+ template: '@SyliusAdmin/shared/crud/common/navbar.html.twig'
+ priority: 100
+ content:
+ template: '@SyliusAdmin/shared/crud/common/content.html.twig'
+ priority: 0
+
+ 'sylius_admin.synolia_gdpr_plugin.index.content':
+ flashes:
+ template: '@SyliusAdmin/shared/crud/common/content/flashes.html.twig'
+ priority: 300
+ header:
+ template: '@SyliusAdmin/shared/crud/common/content/header.html.twig'
+ priority: 200
+ form:
+ template: '@SynoliaSyliusGDPRPlugin/Gdpr/part/form.html.twig'
+ priority: 100
+ footer:
+ template: '@SynoliaSyliusGDPRPlugin/Gdpr/part/footer.html.twig'
+ priority: -100
+
+ 'sylius_admin.synolia_gdpr_plugin.index.content.header':
+ breadcrumbs:
+ template: '@SyliusAdmin/shared/crud/index/content/header/breadcrumbs.html.twig'
+ priority: 100
+ title_block:
+ template: '@SyliusAdmin/shared/crud/common/content/header/title_block.html.twig'
+ priority: 0
+
+ 'sylius_admin.synolia_gdpr_plugin.index.content.header.title_block':
+ title:
+ template: '@SyliusAdmin/shared/crud/common/content/header/title_block/title.html.twig'
+ configuration:
+ title: sylius.ui.admin.synolia_gdpr.advanced_actions.title
+ sylius_test_html_attribute: 'dashboard-header'
+ priority: 100
-# sylius.admin.customer.show.information:
-# blocks:
-# gdpr: '@SynoliaSyliusGDPRPlugin\Admin\Customer\Show\gdpr.html.twig'
diff --git a/src/Resources/config/packages/ui.yaml b/src/Resources/config/packages/ui.yaml
deleted file mode 100644
index bfbb4f9..0000000
--- a/src/Resources/config/packages/ui.yaml
+++ /dev/null
@@ -1,6 +0,0 @@
-#sylius_ui:
-# events:
-# sylius.admin.customer.show.information:
-# blocks:
-# gdpr: '@SynoliaSyliusGDPRPlugin\Admin\Customer\Show\gdpr.html.twig'
-#
diff --git a/src/Resources/views/Admin/Customer/Show/gdpr.html.twig b/src/Resources/views/Admin/Customer/Show/gdpr.html.twig
index fd4c68a..494b54e 100644
--- a/src/Resources/views/Admin/Customer/Show/gdpr.html.twig
+++ b/src/Resources/views/Admin/Customer/Show/gdpr.html.twig
@@ -2,18 +2,24 @@
sylius_plus_rbac_gdpr_has_permission("synolia_sylius_gdpr_admin_anonymize_customer") or
sylius_plus_rbac_gdpr_has_permission("synolia_sylius_gdpr_admin_export_customer_data")
%}
-
-
{{ 'sylius.ui.admin.synolia_gdpr.customer.gdpr_title'|trans }}
-
-
-
-
- {{ 'sylius.ui.admin.synolia_gdpr.customer.export_data'|trans }}
-
+ {% set customer = hookable_metadata.context.customer %}
+
+
+
{{ 'sylius.ui.admin.synolia_gdpr.customer.gdpr_title'|trans }}
+
{% endif %}
diff --git a/src/Resources/views/Admin/layout.html.twig b/src/Resources/views/Admin/layout.html.twig
deleted file mode 100644
index 41c30a7..0000000
--- a/src/Resources/views/Admin/layout.html.twig
+++ /dev/null
@@ -1,16 +0,0 @@
-{% extends '@SyliusAdmin/layout.html.twig' %}
-{% import '@SyliusAdmin/Macro/breadcrumb.html.twig' as breadcrumb %}
-
-{% block title %} | Synolia Sylius GDPR Plugin{% endblock %}
-
-{% set breadcrumbs = breadcrumbs|default([
- {label: 'sylius.ui.administration'|trans, url: path('sylius_admin_dashboard')}
-]) %}
-
-{% block breadcrumb %}
- {{ breadcrumb.crumble(breadcrumbs) }}
-{% endblock %}
-
-{% block footer %}
- {{ 'sylius.ui.powered_by'|trans }}
Synolia. {{ 'sylius.ui.see_issue'|trans }}?
{{ 'sylius.ui.report_it'|trans }}!
-{% endblock %}
\ No newline at end of file
diff --git a/src/Resources/views/Gdpr/Actions.html.twig b/src/Resources/views/Gdpr/Actions.html.twig
index 9a0a675..24e960e 100644
--- a/src/Resources/views/Gdpr/Actions.html.twig
+++ b/src/Resources/views/Gdpr/Actions.html.twig
@@ -1,28 +1,9 @@
-{% extends '@SynoliaSyliusGDPRPlugin/Admin/layout.html.twig' %}
+{% extends '@SyliusAdmin/shared/layout/base.html.twig' %}
-{% import '@SyliusUi/Macro/headers.html.twig' as headers %}
+{% set title = 'sylius.ui.admin.synolia_gdpr.advanced_actions.title'|trans %}
-{% block title %}{{ 'sylius.ui.admin.synolia_gdpr.advanced_actions.title'|trans }} {{ parent() }}{% endblock %}
+{% block title %}{{ 'sylius.ui.admin.synolia_gdpr.advanced_actions.title'|trans }} | Synolia Sylius GDPR Plugin{% endblock %}
-{% block content %}
- {{ headers.default(
- 'sylius.ui.admin.synolia_gdpr.advanced_actions.title'|trans,
- 'cogs',
- ) }}
- {% block breadcrumb %}
- {% set breadcrumbs = breadcrumbs|merge([
- { label: 'sylius.ui.admin.synolia_gdpr.advanced_actions.title'|trans }
- ]) %}
- {{ parent() }}
- {% endblock %}
-
- {% for form in forms %}
-
- {{ form_start(form, {'attr': {'class': 'ui form'}}) }}
-
- {{ form_label(form)}}
-
- {{ form_end(form) }}
-
- {% endfor %}
+{% block body %}
+ {% hook ['sylius_admin.synolia_gdpr_plugin.index'] %}
{% endblock %}
diff --git a/src/Resources/views/Gdpr/part/footer.html.twig b/src/Resources/views/Gdpr/part/footer.html.twig
new file mode 100644
index 0000000..e71e604
--- /dev/null
+++ b/src/Resources/views/Gdpr/part/footer.html.twig
@@ -0,0 +1,9 @@
+
diff --git a/src/Resources/views/Gdpr/part/form.html.twig b/src/Resources/views/Gdpr/part/form.html.twig
new file mode 100644
index 0000000..514e3ba
--- /dev/null
+++ b/src/Resources/views/Gdpr/part/form.html.twig
@@ -0,0 +1,15 @@
+{% set forms = hookable_metadata.context.forms %}
+
+
+ {% for form in forms %}
+
+
+ {% form_theme form '@SyliusAdmin/shared/form_theme.html.twig' %}
+ {{ form_start(form, {'attr': {'class': 'ui form'}}) }}
+ {{ form_label(form) }}
+ {{ form_end(form) }}
+
+
+ {% endfor %}
+
+
diff --git a/src/Twig/GdprExtension.php b/src/Twig/GdprExtension.php
index 3d48d03..232f53f 100644
--- a/src/Twig/GdprExtension.php
+++ b/src/Twig/GdprExtension.php
@@ -10,7 +10,7 @@
final class GdprExtension extends AbstractExtension
{
- public function getFunctions()
+ public function getFunctions(): array
{
return [
new TwigFunction('sylius_plus_rbac_gdpr_has_permission', $this->hasPermission(...), ['needs_environment' => true]),
diff --git a/tests/PHPUnit/Controller/ExportDataControllerTest.php b/tests/PHPUnit/Controller/ExportDataControllerTest.php
index 72457a7..a65007e 100644
--- a/tests/PHPUnit/Controller/ExportDataControllerTest.php
+++ b/tests/PHPUnit/Controller/ExportDataControllerTest.php
@@ -23,11 +23,11 @@ public function testExportDataWithCart(): void
// go to product page
$client->request('GET', '/en_US/products/solar-echo-t-shirt');
- dump($client->getCrawler()->filter('h1')->text());
$this->assertSelectorTextContains('h1', 'Solar Echo T-Shirt');
// add product to cart
$client->submitForm('Add to cart');
+
$client->request('GET', '/en_US/cart/');
$this->assertSelectorTextContains('h1', 'Your shopping cart');
diff --git a/tests/PHPUnit/Fixtures/Foo.php b/tests/PHPUnit/Fixtures/Foo.php
index 8ea4727..cbc9cee 100644
--- a/tests/PHPUnit/Fixtures/Foo.php
+++ b/tests/PHPUnit/Fixtures/Foo.php
@@ -4,7 +4,7 @@
namespace Tests\Synolia\SyliusGDPRPlugin\PHPUnit\Fixtures;
-use Synolia\SyliusGDPRPlugin\Annotation\Anonymize;
+use Synolia\SyliusGDPRPlugin\Attribute\Anonymize;
class Foo
{
From 08cd5f0dd778bb954d3986b97f6a528148eb30d0 Mon Sep 17 00:00:00 2001
From: jb cr <51637606+jbcr@users.noreply.github.com>
Date: Tue, 11 Mar 2025 16:38:04 +0100
Subject: [PATCH 09/17] add fix for Sylius issue 17733
---
src/Resources/config/packages/twig_hooks.yaml | 2 +-
.../views/Gdpr/part/header/breadcrumbs.html.twig | 15 +++++++++++++++
2 files changed, 16 insertions(+), 1 deletion(-)
create mode 100644 src/Resources/views/Gdpr/part/header/breadcrumbs.html.twig
diff --git a/src/Resources/config/packages/twig_hooks.yaml b/src/Resources/config/packages/twig_hooks.yaml
index f1cbfd4..5f81550 100644
--- a/src/Resources/config/packages/twig_hooks.yaml
+++ b/src/Resources/config/packages/twig_hooks.yaml
@@ -32,7 +32,7 @@ sylius_twig_hooks:
'sylius_admin.synolia_gdpr_plugin.index.content.header':
breadcrumbs:
- template: '@SyliusAdmin/shared/crud/index/content/header/breadcrumbs.html.twig'
+ template: '@SynoliaSyliusGDPRPlugin/Gdpr/part/header/breadcrumbs.html.twig'
priority: 100
title_block:
template: '@SyliusAdmin/shared/crud/common/content/header/title_block.html.twig'
diff --git a/src/Resources/views/Gdpr/part/header/breadcrumbs.html.twig b/src/Resources/views/Gdpr/part/header/breadcrumbs.html.twig
new file mode 100644
index 0000000..1d7b740
--- /dev/null
+++ b/src/Resources/views/Gdpr/part/header/breadcrumbs.html.twig
@@ -0,0 +1,15 @@
+{% from '@SyliusAdmin/shared/helper/breadcrumbs.html.twig' import breadcrumbs %}
+
+{% set title_from_context = hookable_metadata.context.title|default(null) %}
+{% set resource_metadata = hookable_metadata.context.metadata|default(null) %}
+
+{% if title_from_context is not null or resource_metadata is not null %}
+ {% set title = title_from_context ?? (resource_metadata.applicationName~'.ui.'~resource_metadata.pluralName) %}
+{% else %}
+ {% set title = hookable_metadata.configuration.title %}
+{% endif %}
+
+{{ breadcrumbs([
+ { 'name': 'Dashboard', 'url': path('sylius_admin_dashboard'), 'active': false },
+ { 'name': title, 'active': true },
+]) }}
From 24c7821b4774f35fbe30d2c1b7dbecd55a3e70e5 Mon Sep 17 00:00:00 2001
From: jb cr <51637606+jbcr@users.noreply.github.com>
Date: Tue, 11 Mar 2025 16:42:22 +0100
Subject: [PATCH 10/17] update GHA workflow
---
.github/workflows/sylius.yaml | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/.github/workflows/sylius.yaml b/.github/workflows/sylius.yaml
index e5c6394..b89678f 100644
--- a/.github/workflows/sylius.yaml
+++ b/.github/workflows/sylius.yaml
@@ -20,16 +20,12 @@ jobs:
- 8.2
- 8.3
sylius:
- - 1.14.0
- 2.0.0
symfony:
- 6.4
+ - 7.2
node:
- 20.x
- exclude:
- -
- sylius: 2.0.0
- symfony: 5.4
env:
APP_ENV: test
package-name: synolia/sylius-gdpr-plugin
From 9565f32203dc517e9b959e025f110f0e3ca73ecf Mon Sep 17 00:00:00 2001
From: jb cr <51637606+jbcr@users.noreply.github.com>
Date: Wed, 12 Mar 2025 09:57:44 +0100
Subject: [PATCH 11/17] clean commented code
---
src/Resources/config/mappings/ShopUser.yaml | 5 -----
1 file changed, 5 deletions(-)
diff --git a/src/Resources/config/mappings/ShopUser.yaml b/src/Resources/config/mappings/ShopUser.yaml
index 71ac9fe..f89869a 100644
--- a/src/Resources/config/mappings/ShopUser.yaml
+++ b/src/Resources/config/mappings/ShopUser.yaml
@@ -22,11 +22,6 @@ Sylius\Component\Core\Model\ShopUser:
faker: dateTime
verifiedAt:
faker: dateTime
-# locked:
-# faker: boolean
-# args: [100]
-# credentialsExpireAt:
-# faker: dateTime
email:
faker: email
unique: true
From 70437089bb3ea9f41790b19b213a5fe54611a81c Mon Sep 17 00:00:00 2001
From: jb cr <51637606+jbcr@users.noreply.github.com>
Date: Wed, 12 Mar 2025 09:58:55 +0100
Subject: [PATCH 12/17] Bump Sylius version
---
Makefile | 2 +-
README.md | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index e22396d..323632a 100644
--- a/Makefile
+++ b/Makefile
@@ -7,7 +7,7 @@ CONSOLE=cd ${TEST_DIRECTORY} && php bin/console -e test
COMPOSER=cd ${TEST_DIRECTORY} && composer
YARN=cd ${TEST_DIRECTORY} && yarn
-SYLIUS_VERSION=1.14.0
+SYLIUS_VERSION=2.0.0
SYMFONY_VERSION=6.4
PHP_VERSION=8.2
PLUGIN_NAME=synolia/sylius-gdpr-plugin
diff --git a/README.md b/README.md
index 208c6e6..4d8cada 100644
--- a/README.md
+++ b/README.md
@@ -34,7 +34,7 @@
| | Version |
|:-------|:--------|
| PHP | ^8.2 |
-| Sylius | ^1.12 |
+| Sylius | ^2.0 |
## Installation
From 12afee798df7a864efb40d1b9ac3fa2de9c98cd0 Mon Sep 17 00:00:00 2001
From: jb cr <51637606+jbcr@users.noreply.github.com>
Date: Wed, 12 Mar 2025 11:18:46 +0100
Subject: [PATCH 13/17] fix customer link to export data
---
src/Resources/views/Admin/Customer/Show/gdpr.html.twig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Resources/views/Admin/Customer/Show/gdpr.html.twig b/src/Resources/views/Admin/Customer/Show/gdpr.html.twig
index 494b54e..fcfa478 100644
--- a/src/Resources/views/Admin/Customer/Show/gdpr.html.twig
+++ b/src/Resources/views/Admin/Customer/Show/gdpr.html.twig
@@ -16,7 +16,7 @@
{{ ux_icon('tabler:database-export') }}{{ 'sylius.ui.admin.synolia_gdpr.customer.export_data'|trans }}
From 4fb91a58bf5c0dfbdbab92f0f843c71c6611f3af Mon Sep 17 00:00:00 2001
From: jb cr <51637606+jbcr@users.noreply.github.com>
Date: Wed, 12 Mar 2025 11:46:09 +0100
Subject: [PATCH 14/17] revers GHA worflow changes
---
.github/workflows/sylius.yaml | 1 -
1 file changed, 1 deletion(-)
diff --git a/.github/workflows/sylius.yaml b/.github/workflows/sylius.yaml
index b89678f..6ef7e50 100644
--- a/.github/workflows/sylius.yaml
+++ b/.github/workflows/sylius.yaml
@@ -3,7 +3,6 @@ name: Install & Test
push:
branches:
- main
- - upgrade_sylius_2.0
paths-ignore:
- README.md
pull_request:
From 781bc54b636dc2767941d6ee35d8e83b79b0aea0 Mon Sep 17 00:00:00 2001
From: jbcr <51637606+jbcr@users.noreply.github.com>
Date: Wed, 2 Apr 2025 11:26:23 +0200
Subject: [PATCH 15/17] Apply suggestions from code review
Co-authored-by: Maxime Pereira-Lima <7437661+maxperei@users.noreply.github.com>
---
src/Resources/views/Admin/Customer/Show/gdpr.html.twig | 9 ++++++---
src/Resources/views/Gdpr/part/footer.html.twig | 9 ++++-----
tests/PHPUnit/Controller/ExportDataControllerTest.php | 2 +-
3 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/src/Resources/views/Admin/Customer/Show/gdpr.html.twig b/src/Resources/views/Admin/Customer/Show/gdpr.html.twig
index fcfa478..a8982a3 100644
--- a/src/Resources/views/Admin/Customer/Show/gdpr.html.twig
+++ b/src/Resources/views/Admin/Customer/Show/gdpr.html.twig
@@ -16,9 +16,12 @@
{{ ux_icon('tabler:database-export') }}{{ 'sylius.ui.admin.synolia_gdpr.customer.export_data'|trans }}
+ href="{{ path('synolia_sylius_gdpr_admin_export_customer_data', {'id': customer.id}) }}"
+ class="btn btn-primary"
+ >
+ {{ ux_icon('tabler:database-export') }}
+ {{ 'sylius.ui.admin.synolia_gdpr.customer.export_data'|trans }}
+
diff --git a/src/Resources/views/Gdpr/part/footer.html.twig b/src/Resources/views/Gdpr/part/footer.html.twig
index e71e604..b036f03 100644
--- a/src/Resources/views/Gdpr/part/footer.html.twig
+++ b/src/Resources/views/Gdpr/part/footer.html.twig
@@ -1,9 +1,8 @@
diff --git a/tests/PHPUnit/Controller/ExportDataControllerTest.php b/tests/PHPUnit/Controller/ExportDataControllerTest.php
index a65007e..2099931 100644
--- a/tests/PHPUnit/Controller/ExportDataControllerTest.php
+++ b/tests/PHPUnit/Controller/ExportDataControllerTest.php
@@ -30,7 +30,7 @@ public function testExportDataWithCart(): void
$client->request('GET', '/en_US/cart/');
- $this->assertSelectorTextContains('h1', 'Your shopping cart');
+ $this->assertPageTitleContains('Your shopping cart');
// login as admin and go to customer page
$adminUser = static::getContainer()->get('sylius.repository.admin_user')->findOneBy([]);
From 83e3c8fcc8a2fc1530cd41cd30423259d68cfb86 Mon Sep 17 00:00:00 2001
From: jb cr <51637606+jbcr@users.noreply.github.com>
Date: Wed, 2 Apr 2025 11:27:00 +0200
Subject: [PATCH 16/17] apply review suggestions
---
compose.yaml | 12 ------------
tests/PHPUnit/Fixtures/Foo.php | 28 ++++++++++------------------
2 files changed, 10 insertions(+), 30 deletions(-)
delete mode 100644 compose.yaml
diff --git a/compose.yaml b/compose.yaml
deleted file mode 100644
index 2f21342..0000000
--- a/compose.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-services:
- mariadb:
- image: 'mariadb:10.5'
- ports:
- - '3306:3306'
- volumes:
- - gdpr_mysql:/var/lib/data
- environment:
- MYSQL_ALLOW_EMPTY_PASSWORD: true
-# options: '--health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3'
-volumes:
- gdpr_mysql: ~
diff --git a/tests/PHPUnit/Fixtures/Foo.php b/tests/PHPUnit/Fixtures/Foo.php
index cbc9cee..ee02362 100644
--- a/tests/PHPUnit/Fixtures/Foo.php
+++ b/tests/PHPUnit/Fixtures/Foo.php
@@ -8,36 +8,28 @@
class Foo
{
- /** @Anonymize(faker="email") */
+ #[Anonymize(['faker' => 'email'])]
public $email = '';
- /** @Anonymize(value="test-annonation-value") */
+ #[Anonymize(['value' => 'test-annonation-value'])]
public $value;
- /** @Anonymize("test-annonation-value-without-property") */
+ #[Anonymize(['value' => 'test-annonation-value-without-property'])]
public $valueWithoutProperty;
- /** @Anonymize(faker="email", prefix="test-annotation-prefix-") */
+ #[Anonymize(['faker' => 'email', 'prefix' => 'test-annotation-prefix-'])]
public $prefix;
- /** @Anonymize(value="value", prefix="test-annotation-prefix-value-") */
+ #[Anonymize(['value' => 'value', 'prefix' => 'test-annotation-prefix-value-'])]
public $prefixValue;
- /** @Anonymize(value="annotation") */
+ #[Anonymize(['value' => 'attribute'])]
public $mergeYamlAnnotationConfiguration;
- /**
- * @var array
- *
- * @Anonymize(value={"value1", "value2"})
- */
- public $arrayValue;
-
- /**
- * @var int
- *
- * @Anonymize(value="1542", prefix="1542")
- */
+ #[Anonymize(['value' => ['value1', 'value2']])]
+ public array $arrayValue;
+
+ #[Anonymize(['value' => '1542', 'prefix' => '1542'])]
public $integer;
public $bar;
From e565f39215d194d1b84af912813f6ac4656b9897 Mon Sep 17 00:00:00 2001
From: jb cr <51637606+jbcr@users.noreply.github.com>
Date: Wed, 2 Apr 2025 15:00:00 +0200
Subject: [PATCH 17/17] add upgrade guide and use loader priority to fix
configuration override order
---
UPGRADE-2.0.md | 5 +++++
.../RegisterAnonymizationLoader.php | 22 ++++++++-----------
src/Loader/ArrayLoader.php | 7 ++++++
src/Loader/AttributeLoader.php | 7 ++++++
src/Loader/LoaderChain.php | 18 +++++++++++++++
src/Loader/LoaderInterface.php | 4 ++++
tests/PHPUnit/Fixtures/Foo.php | 2 +-
7 files changed, 51 insertions(+), 14 deletions(-)
create mode 100644 UPGRADE-2.0.md
diff --git a/UPGRADE-2.0.md b/UPGRADE-2.0.md
new file mode 100644
index 0000000..90b9be2
--- /dev/null
+++ b/UPGRADE-2.0.md
@@ -0,0 +1,5 @@
+# UPGRADE FROM `v1.X` TO `v2.0`
+
+* For each implementation of `Synolia\SyliusGDPRPlugin\Loader\LoaderInterface`, add the `getDefaultPriority` static function.
+* Use attribute instead of annotation.
+* The service tag `anonymization_loader` has been removed. Use `Synolia\SyliusGDPRPlugin\Loader\LoaderInterface` instead.
diff --git a/src/DependencyInjection/CompilerPass/RegisterAnonymizationLoader.php b/src/DependencyInjection/CompilerPass/RegisterAnonymizationLoader.php
index d6b1b7b..3980f5c 100644
--- a/src/DependencyInjection/CompilerPass/RegisterAnonymizationLoader.php
+++ b/src/DependencyInjection/CompilerPass/RegisterAnonymizationLoader.php
@@ -6,7 +6,6 @@
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
-use Symfony\Component\DependencyInjection\Reference;
use Synolia\SyliusGDPRPlugin\Loader\ArrayLoader;
use Synolia\SyliusGDPRPlugin\Loader\LoaderChain;
@@ -14,19 +13,16 @@ final class RegisterAnonymizationLoader implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
- $services = $container->findTaggedServiceIds('anonymization_loader');
- $chainLoader = $container->getDefinition(LoaderChain::class);
-
- foreach (\array_keys($services) as $id) {
- $definition = $container->getDefinition($id);
- if (ArrayLoader::class === $definition->getClass()) {
- $definition->setArgument(
- 0,
- $container->getParameter('synolia_anonymization_mapping'),
- );
- }
- $chainLoader->addMethodCall('addLoader', [new Reference($id)]);
+ if (!$container->has(LoaderChain::class)) {
+ return;
}
+
+ $arrayLoader = $container->getDefinition(ArrayLoader::class);
+ $arrayLoader->setArgument(
+ 0,
+ $container->getParameter('synolia_anonymization_mapping'),
+ );
+
$container->getParameterBag()->remove('synolia_anonymization_mapping');
}
}
diff --git a/src/Loader/ArrayLoader.php b/src/Loader/ArrayLoader.php
index 89eddff..543de89 100644
--- a/src/Loader/ArrayLoader.php
+++ b/src/Loader/ArrayLoader.php
@@ -11,6 +11,8 @@
final readonly class ArrayLoader implements LoaderInterface
{
+ private const PRIORITY = -1024;
+
public function __construct(private array $mappings = [])
{
}
@@ -72,4 +74,9 @@ private function assignAttributeMetaDataCollection(
return $attributeMetaDataCollection;
}
+
+ public static function getDefaultPriority(): int
+ {
+ return self::PRIORITY;
+ }
}
diff --git a/src/Loader/AttributeLoader.php b/src/Loader/AttributeLoader.php
index 11378f0..71881f3 100644
--- a/src/Loader/AttributeLoader.php
+++ b/src/Loader/AttributeLoader.php
@@ -11,6 +11,8 @@
final readonly class AttributeLoader implements LoaderInterface
{
+ private const PRIORITY = 1024;
+
/** @throws \ReflectionException */
public function loadClassMetadata(string $className): AttributeMetadataCollection
{
@@ -36,4 +38,9 @@ public function loadClassMetadata(string $className): AttributeMetadataCollectio
return $attributeMetaDataCollection;
}
+
+ public static function getDefaultPriority(): int
+ {
+ return self::PRIORITY;
+ }
}
diff --git a/src/Loader/LoaderChain.php b/src/Loader/LoaderChain.php
index 5478413..66dce4e 100644
--- a/src/Loader/LoaderChain.php
+++ b/src/Loader/LoaderChain.php
@@ -4,6 +4,7 @@
namespace Synolia\SyliusGDPRPlugin\Loader;
+use Symfony\Component\DependencyInjection\Attribute\AutowireIterator;
use Synolia\SyliusGDPRPlugin\Loader\Mapping\AttributeMetadataCollection;
final class LoaderChain implements LoaderInterface
@@ -11,6 +12,18 @@ final class LoaderChain implements LoaderInterface
/** @var LoaderInterface[] */
private array $loaders = [];
+ public function __construct(
+ #[AutowireIterator(LoaderInterface::class, defaultPriorityMethod: 'getDefaultPriority', exclude: [self::class])]
+ iterable $loaders,
+ ) {
+ foreach ($loaders as $loader) {
+ if (!$loader instanceof LoaderInterface) {
+ throw new \LogicException('Not an anonymization loader');
+ }
+ $this->addLoader($loader);
+ }
+ }
+
public function addLoader(LoaderInterface $loader): void
{
if ($loader instanceof self) {
@@ -33,4 +46,9 @@ public function loadClassMetadata(string $className): AttributeMetadataCollectio
return $fullCollect;
}
+
+ public static function getDefaultPriority(): int
+ {
+ return 0;
+ }
}
diff --git a/src/Loader/LoaderInterface.php b/src/Loader/LoaderInterface.php
index 40026c0..4a836cb 100644
--- a/src/Loader/LoaderInterface.php
+++ b/src/Loader/LoaderInterface.php
@@ -4,9 +4,13 @@
namespace Synolia\SyliusGDPRPlugin\Loader;
+use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
use Synolia\SyliusGDPRPlugin\Loader\Mapping\AttributeMetadataCollection;
+#[AutoconfigureTag]
interface LoaderInterface
{
public function loadClassMetadata(string $className): AttributeMetadataCollection;
+
+ public static function getDefaultPriority(): int;
}
diff --git a/tests/PHPUnit/Fixtures/Foo.php b/tests/PHPUnit/Fixtures/Foo.php
index ee02362..bd7b0e4 100644
--- a/tests/PHPUnit/Fixtures/Foo.php
+++ b/tests/PHPUnit/Fixtures/Foo.php
@@ -30,7 +30,7 @@ class Foo
public array $arrayValue;
#[Anonymize(['value' => '1542', 'prefix' => '1542'])]
- public $integer;
+ public int $integer;
public $bar;
}