From 357cc7021d8f986e4b90b78fbb00eb6cbc1990c9 Mon Sep 17 00:00:00 2001 From: Hotlander Date: Tue, 9 Jun 2020 12:49:07 +0200 Subject: [PATCH 1/2] - updated validation regarding Customer, Company and Address - moved the validation to the correct bundles instead of having it all in the OrderBundle validation file --- .../Resources/config/validation.yml | 13 +++++++++++++ .../CustomerBundle/Form/Type/CompanyType.php | 18 +----------------- .../CustomerBundle/Form/Type/CustomerType.php | 12 +++--------- .../Resources/config/validation.yml | 14 ++++++++++++++ .../Resources/config/validation.yml | 14 -------------- 5 files changed, 31 insertions(+), 40 deletions(-) create mode 100644 src/Marello/Bundle/AddressBundle/Resources/config/validation.yml create mode 100644 src/Marello/Bundle/CustomerBundle/Resources/config/validation.yml diff --git a/src/Marello/Bundle/AddressBundle/Resources/config/validation.yml b/src/Marello/Bundle/AddressBundle/Resources/config/validation.yml new file mode 100644 index 000000000..4b67e5f11 --- /dev/null +++ b/src/Marello/Bundle/AddressBundle/Resources/config/validation.yml @@ -0,0 +1,13 @@ +Marello\Bundle\AddressBundle\Entity\MarelloAddress: + properties: + street: + - NotBlank: ~ + city: + - NotBlank: ~ + postalCode: + - NotBlank: ~ + country: + - NotBlank: ~ + phone: + - Length: + max: 255 diff --git a/src/Marello/Bundle/CustomerBundle/Form/Type/CompanyType.php b/src/Marello/Bundle/CustomerBundle/Form/Type/CompanyType.php index 8f7f6e206..05e534d88 100644 --- a/src/Marello/Bundle/CustomerBundle/Form/Type/CompanyType.php +++ b/src/Marello/Bundle/CustomerBundle/Form/Type/CompanyType.php @@ -73,9 +73,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'mapped' => false, 'multiple' => true, ] - ) - ->addEventListener(FormEvents::PRE_SUBMIT, [$this, 'preSubmit']) - ->addEventListener(FormEvents::POST_SUBMIT, [$this, 'postSubmit']); + ); if ($this->authorizationChecker->isGranted('marello_customer_company_address_update')) { $options = [ @@ -105,20 +103,6 @@ public function buildForm(FormBuilderInterface $builder, array $options) } } - /** - * @param FormEvent $event - */ - public function preSubmit(FormEvent $event) - { - } - - /** - * @param FormEvent $event - */ - public function postSubmit(FormEvent $event) - { - } - /** * {@inheritdoc} */ diff --git a/src/Marello/Bundle/CustomerBundle/Form/Type/CustomerType.php b/src/Marello/Bundle/CustomerBundle/Form/Type/CustomerType.php index 34d732f31..b11a96c58 100644 --- a/src/Marello/Bundle/CustomerBundle/Form/Type/CustomerType.php +++ b/src/Marello/Bundle/CustomerBundle/Form/Type/CustomerType.php @@ -28,25 +28,19 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'required' => false, ]) ->add('firstName', TextType::class, [ - 'required' => true, - 'constraints' => new NotNull, + 'required' => true ]) ->add('middleName', TextType::class, [ 'required' => false, ]) ->add('lastName', TextType::class, [ - 'required' => true, - 'constraints' => new NotNull, + 'required' => true ]) ->add('nameSuffix', TextType::class, [ 'required' => false, ]) ->add('email', EmailType::class, [ - 'required' => true, - 'constraints' => [ - new NotNull, - new Email, - ], + 'required' => true ]) ->add('taxIdentificationNumber', TextType::class, [ 'required' => false, diff --git a/src/Marello/Bundle/CustomerBundle/Resources/config/validation.yml b/src/Marello/Bundle/CustomerBundle/Resources/config/validation.yml new file mode 100644 index 000000000..c1e8c682c --- /dev/null +++ b/src/Marello/Bundle/CustomerBundle/Resources/config/validation.yml @@ -0,0 +1,14 @@ +Marello\Bundle\CustomerBundle\Entity\Customer: + properties: + firstName: + - NotBlank: ~ + lastName: + - NotBlank: ~ + email: + - NotBlank: ~ + - Email: ~ + +Marello\Bundle\CustomerBundle\Entity\Company: + properties: + name: + - NotBlank: ~ \ No newline at end of file diff --git a/src/Marello/Bundle/OrderBundle/Resources/config/validation.yml b/src/Marello/Bundle/OrderBundle/Resources/config/validation.yml index 06fe452ad..507cce212 100644 --- a/src/Marello/Bundle/OrderBundle/Resources/config/validation.yml +++ b/src/Marello/Bundle/OrderBundle/Resources/config/validation.yml @@ -1,17 +1,3 @@ -Marello\Bundle\AddressBundle\Entity\MarelloAddress: - properties: - street: - - NotBlank: ~ - city: - - NotBlank: ~ - postalCode: - - NotBlank: ~ - country: - - NotBlank: ~ - phone: - - Length: - max: 255 - Marello\Bundle\OrderBundle\Entity\OrderItem: properties: product: From a61f403be27a42fa7e864ddacf31d3eb45a675cd Mon Sep 17 00:00:00 2001 From: Hotlander Date: Wed, 10 Jun 2020 11:21:39 +0200 Subject: [PATCH 2/2] - added missing validator translations regarding shipping method rules and configs --- .../ShippingBundle/Resources/translations/validators.en.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/Marello/Bundle/ShippingBundle/Resources/translations/validators.en.yml diff --git a/src/Marello/Bundle/ShippingBundle/Resources/translations/validators.en.yml b/src/Marello/Bundle/ShippingBundle/Resources/translations/validators.en.yml new file mode 100644 index 000000000..e0323d070 --- /dev/null +++ b/src/Marello/Bundle/ShippingBundle/Resources/translations/validators.en.yml @@ -0,0 +1,6 @@ +marello: + shipping: + shippingrule: + enabled.message: 'Shipping method can not be enabled' + type.config.count.message: 'At least one shipping method needs to be enabled in this group' + method.config.count.message: 'At least one shipping method needs to be configured for this rule.' \ No newline at end of file