From d60e5b105550e54139c1d7e3e282c69e97281bc5 Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Sun, 1 Oct 2023 18:27:04 +0200 Subject: [PATCH] Use FurtherInformation element in HtmlOutput --- src/PaymentPart/Output/HtmlOutput/HtmlOutput.php | 13 ++++++++++++- .../Template/FurtherInformationElementTemplate.php | 10 ++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 src/PaymentPart/Output/HtmlOutput/Template/FurtherInformationElementTemplate.php diff --git a/src/PaymentPart/Output/HtmlOutput/HtmlOutput.php b/src/PaymentPart/Output/HtmlOutput/HtmlOutput.php index 0462b966..73b23e65 100644 --- a/src/PaymentPart/Output/HtmlOutput/HtmlOutput.php +++ b/src/PaymentPart/Output/HtmlOutput/HtmlOutput.php @@ -3,9 +3,11 @@ namespace Sprain\SwissQrBill\PaymentPart\Output\HtmlOutput; use Sprain\SwissQrBill\PaymentPart\Output\AbstractOutput; +use Sprain\SwissQrBill\PaymentPart\Output\Element\FurtherInformation; use Sprain\SwissQrBill\PaymentPart\Output\Element\Placeholder; use Sprain\SwissQrBill\PaymentPart\Output\Element\Text; use Sprain\SwissQrBill\PaymentPart\Output\Element\Title; +use Sprain\SwissQrBill\PaymentPart\Output\HtmlOutput\Template\FurtherInformationElementTemplate; use Sprain\SwissQrBill\PaymentPart\Output\HtmlOutput\Template\PlaceholderElementTemplate; use Sprain\SwissQrBill\PaymentPart\Output\HtmlOutput\Template\PrintableStylesTemplate; use Sprain\SwissQrBill\PaymentPart\Output\HtmlOutput\Template\TextElementTemplate; @@ -133,11 +135,12 @@ private function hideSeparatorContentIfPrintable(string $paymentPart): string return $paymentPart; } - private function getContentElement(Title|Text|Placeholder $element): string + private function getContentElement(FurtherInformation|Title|Text|Placeholder $element): string { # https://github.com/phpstan/phpstan/issues/4451 # @phpstan-ignore-next-line return match (get_class($element)) { + FurtherInformation::class => $this->getFurtherInformationElement($element), Title::class => $this->getTitleElement($element), Text::class => $this->getTextElement($element), Placeholder::class => $this->getPlaceholderElement($element) @@ -160,6 +163,14 @@ private function getTextElement(Text $element): string return $elementString; } + private function getFurtherInformationElement(FurtherInformation $element): string + { + $elementTemplate = FurtherInformationElementTemplate::TEMPLATE; + $elementString = str_replace('{{ text }}', nl2br($element->getText()), $elementTemplate); + + return $elementString; + } + private function getPlaceholderElement(Placeholder $element): string { $elementTemplate = PlaceholderElementTemplate::TEMPLATE; diff --git a/src/PaymentPart/Output/HtmlOutput/Template/FurtherInformationElementTemplate.php b/src/PaymentPart/Output/HtmlOutput/Template/FurtherInformationElementTemplate.php new file mode 100644 index 00000000..d868503a --- /dev/null +++ b/src/PaymentPart/Output/HtmlOutput/Template/FurtherInformationElementTemplate.php @@ -0,0 +1,10 @@ +{{ text }}

+EOT; +}