From f9d60760968d4275677443fedafe1f239bb4a2bd Mon Sep 17 00:00:00 2001 From: DominikWolos Date: Thu, 20 Jan 2022 12:21:37 +0100 Subject: [PATCH 1/4] Fixed errors which occured after minor fixes --- src/Entity/Agreement/AgreementsRequiredTrait.php | 2 +- .../Admin/AgreementAutocompleteChoiceType.php | 10 +++++++++- src/Form/Type/Agreement/Admin/AgreementType.php | 8 +++----- .../Type/Agreement/Shop/AgreementCollectionType.php | 1 - src/Resources/config/config.yaml | 3 +-- src/Resources/config/routes.yaml | 3 --- src/Resources/config/routing/admin.yaml | 2 +- src/Resources/config/services.xml | 8 ++++---- .../Admin/Form/agreement_autocomplete_choice.html.twig | 2 +- tests/Application/config/packages/_sylius.yaml | 9 +++++++-- .../src/Entity/Customer/CustomerInterface.php | 1 - tests/Application/src/Resources/config/config.yaml | 5 ----- 12 files changed, 27 insertions(+), 27 deletions(-) delete mode 100644 src/Resources/config/routes.yaml delete mode 100644 tests/Application/src/Resources/config/config.yaml diff --git a/src/Entity/Agreement/AgreementsRequiredTrait.php b/src/Entity/Agreement/AgreementsRequiredTrait.php index 33a9215f..25e90e68 100644 --- a/src/Entity/Agreement/AgreementsRequiredTrait.php +++ b/src/Entity/Agreement/AgreementsRequiredTrait.php @@ -8,7 +8,7 @@ trait AgreementsRequiredTrait { - /** @var Collection|AgreementInterface[] */ + /** @var ?Collection|AgreementInterface[] */ protected $agreements; public function getAgreements(): ?Collection diff --git a/src/Form/Type/Agreement/Admin/AgreementAutocompleteChoiceType.php b/src/Form/Type/Agreement/Admin/AgreementAutocompleteChoiceType.php index 714db8e4..7e078153 100644 --- a/src/Form/Type/Agreement/Admin/AgreementAutocompleteChoiceType.php +++ b/src/Form/Type/Agreement/Admin/AgreementAutocompleteChoiceType.php @@ -6,6 +6,8 @@ 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; class AgreementAutocompleteChoiceType extends AbstractType @@ -23,12 +25,18 @@ public function configureOptions(OptionsResolver $resolver): void ]); } + public function buildView(FormView $view, FormInterface $form, array $options): void + { + $view->vars['remote_criteria_type'] = 'contains'; + $view->vars['remote_criteria_name'] = 'phrase'; + } + /** * @inheritdoc */ public function getBlockPrefix(): string { - return 'bitbag_sylius_agreement_plugin_autocomplete_choice'; + return 'bitbag_sylius_agreement_plugin_admin_ajax_agreement_choice'; } /** diff --git a/src/Form/Type/Agreement/Admin/AgreementType.php b/src/Form/Type/Agreement/Admin/AgreementType.php index 7d6cdfb1..f98a06a7 100644 --- a/src/Form/Type/Agreement/Admin/AgreementType.php +++ b/src/Form/Type/Agreement/Admin/AgreementType.php @@ -66,11 +66,8 @@ public function buildForm(FormBuilderInterface $builder, array $options): void $contexts = $this->prepareContextsData(); $builder - ->add('parent', AgreementAutocompleteChoiceType::class, [ - 'label' => 'bitbag_sylius_agreement_plugin.ui.agreement', - 'resource' => 'bitbag_sylius_agreement_plugin.agreement', - 'choice_name' => 'code', - 'choice_value' => 'id', + ->add('parent', TextType::class, [ + 'label' => 'bitbag_sylius_agreement_plugin.ui.agreement' ]) ->add('code', TextType::class, [ 'label' => 'bitbag_sylius_agreement_plugin.ui.code', @@ -112,6 +109,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void )->addModelTransformer( new ResourceToIdentifierTransformer($this->agreementRepository, 'id') ); + } public function getBlockPrefix(): string diff --git a/src/Form/Type/Agreement/Shop/AgreementCollectionType.php b/src/Form/Type/Agreement/Shop/AgreementCollectionType.php index 574fd239..70c89a0e 100644 --- a/src/Form/Type/Agreement/Shop/AgreementCollectionType.php +++ b/src/Form/Type/Agreement/Shop/AgreementCollectionType.php @@ -36,7 +36,6 @@ public function configureOptions(OptionsResolver $resolver): void ->setDefault('entry_options', static function (AgreementInterface $agreement): array { /** @var AgreementTranslationInterface $translation */ $translation = $agreement->getTranslation(); - return [ 'required' => in_array( $agreement->getMode(), diff --git a/src/Resources/config/config.yaml b/src/Resources/config/config.yaml index bfbc1995..2bf5f880 100755 --- a/src/Resources/config/config.yaml +++ b/src/Resources/config/config.yaml @@ -1,6 +1,6 @@ imports: - { resource: "@SyliusAgreementPlugin/Resources/config/resources.yaml" } - - { resource: "@SyliusAgreementPlugin/Resources/config/grids/admin/agreement.yaml" } + - { resource: "@SyliusAgreementPlugin/Resources/config/grids/*/*.yaml" } sylius_agreement: extended_form_types: @@ -15,4 +15,3 @@ sylius_agreement: twig: form_themes: - '@SyliusAgreementPlugin/Form/agreement_approval_widget.html.twig' - - '@SyliusAgreementPlugin/Admin/Form/agreement_autocomplete_choice.html.twig' diff --git a/src/Resources/config/routes.yaml b/src/Resources/config/routes.yaml deleted file mode 100644 index 3fe385a2..00000000 --- a/src/Resources/config/routes.yaml +++ /dev/null @@ -1,3 +0,0 @@ -bitbag_sylius_agreement_plugin_admin: - resource: "@SyliusAgreementPlugin/Resources/config/routing/admin.yaml" - prefix: '/%sylius_admin.path_name%' diff --git a/src/Resources/config/routing/admin.yaml b/src/Resources/config/routing/admin.yaml index a49f9f26..883c9b1c 100644 --- a/src/Resources/config/routing/admin.yaml +++ b/src/Resources/config/routing/admin.yaml @@ -28,7 +28,7 @@ bitbag_sylius_agreement_plugin_admin_agreement_archive: parameters: {} bitbag_sylius_agreement_plugin_admin_ajax_agreement_choice: - path: /agreements/new/search + path: /admin/agreement/search methods: [GET] defaults: _controller: bitbag_sylius_agreement_plugin.controller.agreement:indexAction diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml index 71a44f15..da241226 100644 --- a/src/Resources/config/services.xml +++ b/src/Resources/config/services.xml @@ -16,6 +16,7 @@ %bitbag_sylius_agreement_plugin.model.agreement.class% + %bitbag_sylius_agreement_plugin.form.type.agreement.validation_groups% %sylius_agreement_plugin.modes% %sylius_agreement_plugin.contexts% @@ -42,7 +43,7 @@ - + @@ -74,13 +75,12 @@ - + - - + Date: Thu, 20 Jan 2022 12:25:19 +0100 Subject: [PATCH 2/4] ECS fix --- .../Agreement/Admin/AgreementAutocompleteChoiceType.php | 6 +++++- src/Form/Type/Agreement/Admin/AgreementType.php | 3 +-- src/Form/Type/Agreement/Shop/AgreementCollectionType.php | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Form/Type/Agreement/Admin/AgreementAutocompleteChoiceType.php b/src/Form/Type/Agreement/Admin/AgreementAutocompleteChoiceType.php index 7e078153..25b1dd97 100644 --- a/src/Form/Type/Agreement/Admin/AgreementAutocompleteChoiceType.php +++ b/src/Form/Type/Agreement/Admin/AgreementAutocompleteChoiceType.php @@ -25,7 +25,11 @@ public function configureOptions(OptionsResolver $resolver): void ]); } - public function buildView(FormView $view, FormInterface $form, array $options): void + public function buildView( + FormView $view, + FormInterface $form, + array $options + ): void { $view->vars['remote_criteria_type'] = 'contains'; $view->vars['remote_criteria_name'] = 'phrase'; diff --git a/src/Form/Type/Agreement/Admin/AgreementType.php b/src/Form/Type/Agreement/Admin/AgreementType.php index f98a06a7..ed5d4f7a 100644 --- a/src/Form/Type/Agreement/Admin/AgreementType.php +++ b/src/Form/Type/Agreement/Admin/AgreementType.php @@ -67,7 +67,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void $builder ->add('parent', TextType::class, [ - 'label' => 'bitbag_sylius_agreement_plugin.ui.agreement' + 'label' => 'bitbag_sylius_agreement_plugin.ui.agreement', ]) ->add('code', TextType::class, [ 'label' => 'bitbag_sylius_agreement_plugin.ui.code', @@ -109,7 +109,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void )->addModelTransformer( new ResourceToIdentifierTransformer($this->agreementRepository, 'id') ); - } public function getBlockPrefix(): string diff --git a/src/Form/Type/Agreement/Shop/AgreementCollectionType.php b/src/Form/Type/Agreement/Shop/AgreementCollectionType.php index 70c89a0e..574fd239 100644 --- a/src/Form/Type/Agreement/Shop/AgreementCollectionType.php +++ b/src/Form/Type/Agreement/Shop/AgreementCollectionType.php @@ -36,6 +36,7 @@ public function configureOptions(OptionsResolver $resolver): void ->setDefault('entry_options', static function (AgreementInterface $agreement): array { /** @var AgreementTranslationInterface $translation */ $translation = $agreement->getTranslation(); + return [ 'required' => in_array( $agreement->getMode(), From d38739e0f573005a6dd4406f5411619ee191bc0b Mon Sep 17 00:00:00 2001 From: DominikWolos Date: Thu, 20 Jan 2022 12:41:25 +0100 Subject: [PATCH 3/4] ECS fix --- .../Type/Agreement/Admin/AgreementAutocompleteChoiceType.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Form/Type/Agreement/Admin/AgreementAutocompleteChoiceType.php b/src/Form/Type/Agreement/Admin/AgreementAutocompleteChoiceType.php index 25b1dd97..1c6d000b 100644 --- a/src/Form/Type/Agreement/Admin/AgreementAutocompleteChoiceType.php +++ b/src/Form/Type/Agreement/Admin/AgreementAutocompleteChoiceType.php @@ -29,8 +29,7 @@ public function buildView( FormView $view, FormInterface $form, array $options - ): void - { + ): void { $view->vars['remote_criteria_type'] = 'contains'; $view->vars['remote_criteria_name'] = 'phrase'; } From 53c7e480dc4e30a646d3bf0ee441d0eaeeff3ce3 Mon Sep 17 00:00:00 2001 From: DominikWolos <91727664+DominikWolos@users.noreply.github.com> Date: Thu, 20 Jan 2022 12:59:16 +0100 Subject: [PATCH 4/4] Update _sylius.yaml --- tests/Application/config/packages/_sylius.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Application/config/packages/_sylius.yaml b/tests/Application/config/packages/_sylius.yaml index 3ea10921..7ea8e9a5 100644 --- a/tests/Application/config/packages/_sylius.yaml +++ b/tests/Application/config/packages/_sylius.yaml @@ -17,8 +17,8 @@ sylius_shop: include_all_descendants: true sylius_customer: - resources: - customer: - classes: - model: Tests\BitBag\SyliusAgreementPlugin\Entity\Customer\Customer + resources: + customer: + classes: + model: Tests\BitBag\SyliusAgreementPlugin\Entity\Customer\Customer