From d39aa94c0c83f72435e5e3233d9dac97da6d25f2 Mon Sep 17 00:00:00 2001 From: PiotrSzymanski2000 Date: Fri, 7 Jan 2022 09:48:22 +0100 Subject: [PATCH 1/3] add new parameter to constructor in form with customer group --- src/Form/Type/BlacklistingRuleType.php | 11 ++++++++++- src/Resources/config/services/form.xml | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Form/Type/BlacklistingRuleType.php b/src/Form/Type/BlacklistingRuleType.php index efc4de3..1e317ed 100644 --- a/src/Form/Type/BlacklistingRuleType.php +++ b/src/Form/Type/BlacklistingRuleType.php @@ -25,11 +25,20 @@ final class BlacklistingRuleType extends AbstractResourceType /** @var array */ private $attributeChoices; - public function __construct(string $dataClass, array $attributeChoices, array $validationGroups = []) + /* @var string */ + private $customerGroupClass; + + public function __construct( + string $dataClass, + array $attributeChoices, + string $customerGroupClass, + array $validationGroups = [] + ) { parent::__construct($dataClass, $validationGroups); $this->attributeChoices = $attributeChoices; + $this->customerGroupClass = $customerGroupClass; } public function buildForm(FormBuilderInterface $builder, array $options): void diff --git a/src/Resources/config/services/form.xml b/src/Resources/config/services/form.xml index 406ea47..8f62424 100644 --- a/src/Resources/config/services/form.xml +++ b/src/Resources/config/services/form.xml @@ -22,6 +22,7 @@ %bitbag_sylius_blacklist_plugin.model.blacklisting_rule.class% %bitbag_sylius_blacklist_plugin.blacklisting_rule_attribute_choices% + %sylius.model.customer_group.class% %bitbag.sylius_blacklist_plugin.form.type.validation_groups% From fa2ff4f3b8c6e6aef09b9ef57e6a44ef22bb05e9 Mon Sep 17 00:00:00 2001 From: PiotrSzymanski2000 Date: Fri, 7 Jan 2022 10:31:20 +0100 Subject: [PATCH 2/3] add flexibility for customer group classes in BlacklistingRuleType --- src/Form/Type/BlacklistingRuleType.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Form/Type/BlacklistingRuleType.php b/src/Form/Type/BlacklistingRuleType.php index 1e317ed..0d6057e 100644 --- a/src/Form/Type/BlacklistingRuleType.php +++ b/src/Form/Type/BlacklistingRuleType.php @@ -63,7 +63,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'label' => 'bitbag_sylius_blacklist_plugin.form.blacklisting_rule.channels', ]) ->add('customerGroups', EntityType::class, [ - 'class' => CustomerGroup::class, + 'class' => $this->customerGroupClass, 'multiple' => true, 'expanded' => true, 'label' => 'bitbag_sylius_blacklist_plugin.form.blacklisting_rule.customer_group', From c0379983a8d36e8913d4f40fee00899dd69ddf91 Mon Sep 17 00:00:00 2001 From: PiotrSzymanski2000 Date: Fri, 7 Jan 2022 10:36:17 +0100 Subject: [PATCH 3/3] refactor code style --- src/Form/Type/BlacklistingRuleType.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Form/Type/BlacklistingRuleType.php b/src/Form/Type/BlacklistingRuleType.php index 0d6057e..127bcd7 100644 --- a/src/Form/Type/BlacklistingRuleType.php +++ b/src/Form/Type/BlacklistingRuleType.php @@ -33,8 +33,7 @@ public function __construct( array $attributeChoices, string $customerGroupClass, array $validationGroups = [] - ) - { + ) { parent::__construct($dataClass, $validationGroups); $this->attributeChoices = $attributeChoices;