From 3149fff59bdb456a86153ce51bea2720b196696a Mon Sep 17 00:00:00 2001 From: Masoud Hedayati Date: Mon, 6 Oct 2025 10:27:00 +0200 Subject: [PATCH 1/3] repair multiple updload and replace email action --- Classes/Helper/PaperTigerHelper.php | 14 +++++++++++ .../Action/Email/Email.Definition.fusion | 25 +++++++++++++++---- NodeTypes/Form.fusion | 4 +-- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/Classes/Helper/PaperTigerHelper.php b/Classes/Helper/PaperTigerHelper.php index b0ce8d3..90c74fa 100644 --- a/Classes/Helper/PaperTigerHelper.php +++ b/Classes/Helper/PaperTigerHelper.php @@ -18,6 +18,20 @@ public function timestampWithHmac(): string return $this->hashService->appendHmac((string) time()); } + function flattenArray(array $array): array { + $result = []; + + foreach ($array as $item) { + if (is_array($item)) { + $result = array_merge($result, $this->flattenArray($item)); + } else { + $result[] = $item; + } + } + + return $result; + } + public function allowsCallOfMethod($methodName) { return true; diff --git a/NodeTypes/Action/Email/Email.Definition.fusion b/NodeTypes/Action/Email/Email.Definition.fusion index 029b95a..ad7609c 100644 --- a/NodeTypes/Action/Email/Email.Definition.fusion +++ b/NodeTypes/Action/Email/Email.Definition.fusion @@ -24,15 +24,15 @@ prototype(Sitegeist.PaperTiger:Action.Email.Definition) < prototype(Neos.Fusion: renderer = Sitegeist.PaperTiger:Action { @if.minRequirementsAreMet = ${props.recipientAddress && props.senderAddress && props.subject && (props.plaintext || props.html)} - type = 'Sitegeist.Neos.SymfonyMailer:SendMail' + type = 'Neos.Fusion.Form.Runtime:Email' options { subject = ${props.subject} text = ${props.plaintext} html = ${props.html} recipientAddress = ${props.recipientAddress} - recipientName = ${props.recipientName} + recipientName = ${props.recipientName ? props.recipientName : ''} senderAddress = ${props.senderAddress} - senderName = ${props.senderName} + senderName = ${props.senderName ? props.senderName : ''} replyToAddress = ${props.replyToAddress} carbonCopyAddress = ${props.carbonCopyAddress} blindCarbonCopyAddress = ${props.blindCarbonCopyAddress} @@ -40,9 +40,24 @@ prototype(Sitegeist.PaperTiger:Action.Email.Definition) < prototype(Neos.Fusion: @if.isEnabled = ${props.attachUploads} items = ${data} itemName = "item" - itemRenderer = ${item} - itemRenderer.@if.isUpload = ${Type.instance(item, '\\Neos\\Flow\\ResourceManagement\\PersistentResource') || Type.instance(item, '\\Psr\\Http\\Message\\UploadedFileInterface') || Type.instance(item, '\\Sitegeist\\FusionForm\\Upload\\Domain\\CachedUploadedFileCollection')} + itemRenderer = Neos.Fusion:Case { + multipleUpload { + condition = ${Type.instance(item, '\\Sitegeist\\FusionForm\\Upload\\Domain\\CachedUploadedFileCollection' )} + renderer = Neos.Fusion:Map { + items = ${item} + itemName = 'uploadFile' + itemRenderer = ${uploadFile} + } + } + + default { + condition = true + renderer = ${item} + } + } + itemRenderer.@if.isUpload = ${Type.instance(item, '\\Neos\\Flow\\ResourceManagement\\PersistentResource') || Type.instance(item, '\\Psr\\Http\\Message\\UploadedFileInterface') || Type.instance(item, '\\Sitegeist\\FusionForm\\Upload\\Domain\\CachedUploadedFileCollection' )} @process.filterEmpty = ${Array.filter(value)} + @process.flattenArray = ${PaperTiger.flattenArray(value)} } testMode = ${props.testMode} } diff --git a/NodeTypes/Form.fusion b/NodeTypes/Form.fusion index f9fb522..68c23ab 100644 --- a/NodeTypes/Form.fusion +++ b/NodeTypes/Form.fusion @@ -1,8 +1,8 @@ prototype(Sitegeist.PaperTiger:Form) < prototype(Neos.Neos:ContentComponent) { class = '' - action = ${'#form_' + node.identifier} - anchor = afx`` + action = ${'#form_' + node.aggregateId} + anchor = afx`` backendStyle = ${StaticResource.content('Sitegeist.PaperTiger', 'Public/Styles/Backend.css')} backendScript = ${StaticResource.content('Sitegeist.PaperTiger', 'Public/Scripts/Backend.js')} From 2ff9a934811825a31e87a46783821c4335ecc152 Mon Sep 17 00:00:00 2001 From: Martin Ficzel Date: Fri, 10 Oct 2025 14:16:01 +0200 Subject: [PATCH 2/3] TASK: Adjust php formatting style --- Classes/Helper/PaperTigerHelper.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Classes/Helper/PaperTigerHelper.php b/Classes/Helper/PaperTigerHelper.php index 90c74fa..4be3374 100644 --- a/Classes/Helper/PaperTigerHelper.php +++ b/Classes/Helper/PaperTigerHelper.php @@ -18,7 +18,12 @@ public function timestampWithHmac(): string return $this->hashService->appendHmac((string) time()); } - function flattenArray(array $array): array { + /** + * @param array> $array + * @return array + */ + public function flattenArray(array $array): array + { $result = []; foreach ($array as $item) { From 4e5857faa927b48ccdffa13edc69c059646e2e68 Mon Sep 17 00:00:00 2001 From: Martin Ficzel Date: Fri, 10 Oct 2025 14:30:17 +0200 Subject: [PATCH 3/3] TASK: Add test for the new flattenArray function --- Tests/Unit/HelperTest.php | 47 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Tests/Unit/HelperTest.php diff --git a/Tests/Unit/HelperTest.php b/Tests/Unit/HelperTest.php new file mode 100644 index 0000000..26078d1 --- /dev/null +++ b/Tests/Unit/HelperTest.php @@ -0,0 +1,47 @@ +helper = new PaperTigerHelper(); + } + + public function flattenArrayWorksDataProvider(): \Generator + { + yield 'plain array stays plain' => [ + ['foo', 'bar', 'baz'], + ['foo', 'bar', 'baz'], + ]; + + yield 'subkeys are expanded' => [ + ['foo', ['bar', 'baz']], + ['foo', 'bar', 'baz'], + ]; + + yield 'sub sub keys aswell' => [ + ['foo', ['bar', ['baz']]], + ['foo', 'bar', 'baz'], + ]; + } + + /** + * @test + * @dataProvider flattenArrayWorksDataProvider + */ + public function flattenArrayWorks(array $source, array $expected): void + { + + $this->assertSame($expected, $this->helper->flattenArray($source)); + } +}