diff --git a/src/Marello/Bundle/NotificationBundle/Email/SendProcessor.php b/src/Marello/Bundle/NotificationBundle/Email/SendProcessor.php index 80a3b98ab..7119febc9 100644 --- a/src/Marello/Bundle/NotificationBundle/Email/SendProcessor.php +++ b/src/Marello/Bundle/NotificationBundle/Email/SendProcessor.php @@ -117,6 +117,11 @@ public function sendNotification($templateName, array $recipients, $entity, arra ) ); } + + if ($this->recipientsNullOrEmpty($recipients)) { + return; + } + $emailModel = $this->emailTemplateManager->getLocalizedModel($template, $entity); if (null === $emailModel) { $emailModel = $this->createEmailModel($template); @@ -240,4 +245,24 @@ private function getTemplateContentType(EmailTemplateInterface $emailTemplate) ? EmailTemplateModel::CONTENT_TYPE_HTML : EmailTemplateModel::CONTENT_TYPE_TEXT; } + + /** + * check if recipients are available for sending out the email notification + * @param array $recipients + * @return bool + */ + private function recipientsNullOrEmpty(array $recipients) + { + if (empty($recipients)) { + return true; + } + + foreach ($recipients as $recipient) { + if (null === $recipient) { + return true; + } + } + + return false; + } } diff --git a/src/Marello/Bundle/OrderBundle/Resources/config/validation.yml b/src/Marello/Bundle/OrderBundle/Resources/config/validation.yml index 3a483cbef..06fe452ad 100644 --- a/src/Marello/Bundle/OrderBundle/Resources/config/validation.yml +++ b/src/Marello/Bundle/OrderBundle/Resources/config/validation.yml @@ -36,16 +36,16 @@ Marello\Bundle\OrderBundle\Entity\OrderItem: Marello\Bundle\OrderBundle\Entity\Order: properties: customer: - - NotBlank: ~ + - NotBlank: { groups: [Default] } salesChannel: - - NotBlank: ~ + - NotBlank: { groups: [Default, commerce] } paymentMethod: - - NotBlank: ~ + - NotBlank: { groups: [Default, commerce] } shippingMethod: - - NotBlank: ~ + - NotBlank: { groups: [Default, commerce] } billingAddress: - - NotBlank: - message: 'marello.order.address.validation.billing_not_blank' + - NotBlank: { groups: [Default, commerce], message: 'marello.order.address.validation.billing_not_blank' } + shippingAddress: - - NotBlank: - message: 'marello.order.address.validation.shipping_not_blank' + - NotBlank: { groups: [Default, commerce], message: 'marello.order.address.validation.shipping_not_blank' } +