From 08b539de18f42fb65380ae7e7dcafac5aeca5ea3 Mon Sep 17 00:00:00 2001 From: sabrinefk13 Date: Wed, 9 Sep 2020 08:48:59 +0200 Subject: [PATCH] Fix HasBackgroundImageValidator --- .../views/Shop/GiftCard/pdf.html.twig | 31 +++++++++++++------ .../HasBackgroundImageValidator.php | 7 ++++- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/Resources/views/Shop/GiftCard/pdf.html.twig b/src/Resources/views/Shop/GiftCard/pdf.html.twig index 554e0b4c..6cdcf3ee 100644 --- a/src/Resources/views/Shop/GiftCard/pdf.html.twig +++ b/src/Resources/views/Shop/GiftCard/pdf.html.twig @@ -1,17 +1,28 @@ +{% set path = '' %} +{% if configuration.backgroundImage is not empty %} + {% set path = configuration.backgroundImage.path|imagine_filter('setono_sylius_gift_card_background') %} +{% endif %} + + Gift card: {{ giftCard.code }} + + -{% if configuration.backgroundImage is not empty %} - {% set path = configuration.backgroundImage.path|imagine_filter('setono_sylius_gift_card_background') %} - -{% endif %} - - {{- giftCard.code -}} - - - {{- giftCard.amount|sylius_format_money(giftCard.currencyCode, sylius_base_locale) -}} - +{{- giftCard.code -}}
+{{- giftCard.amount|sylius_format_money(giftCard.currencyCode, sylius_base_locale) -}} diff --git a/src/Validator/Constraints/HasBackgroundImageValidator.php b/src/Validator/Constraints/HasBackgroundImageValidator.php index ef14c387..07e9075f 100644 --- a/src/Validator/Constraints/HasBackgroundImageValidator.php +++ b/src/Validator/Constraints/HasBackgroundImageValidator.php @@ -22,7 +22,12 @@ public function validate($value, Constraint $constraint): void } $backgroundImage = $value->getBackgroundImage(); - if (null === $backgroundImage || null === $backgroundImage->getPath()) { + + if (null === $backgroundImage) { + return; + } + + if (null === $backgroundImage->getFile()) { $this->context->buildViolation($constraint->message) ->addViolation(); }