Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Classes/Helper/PaperTigerHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,25 @@ public function timestampWithHmac(): string
return $this->hashService->appendHmac((string) time());
}

/**
* @param array<int|string, mixed|array<mixed>> $array
* @return array<int|string, mixed>
*/
public 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;
Expand Down
25 changes: 20 additions & 5 deletions NodeTypes/Action/Email/Email.Definition.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,40 @@ 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}
attachments = Neos.Fusion:Map {
@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}
}
Expand Down
4 changes: 2 additions & 2 deletions NodeTypes/Form.fusion
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
prototype(Sitegeist.PaperTiger:Form) < prototype(Neos.Neos:ContentComponent) {

class = ''
action = ${'#form_' + node.identifier}
anchor = afx`<a id={'form_' + node.identifier}></a>`
action = ${'#form_' + node.aggregateId}
anchor = afx`<a id={'form_' + node.aggregateId}></a>`

backendStyle = ${StaticResource.content('Sitegeist.PaperTiger', 'Public/Styles/Backend.css')}
backendScript = ${StaticResource.content('Sitegeist.PaperTiger', 'Public/Scripts/Backend.js')}
Expand Down
47 changes: 47 additions & 0 deletions Tests/Unit/HelperTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
declare(strict_types=1);

namespace Sitegeist\PaperTiger\Tests\Unit;

use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Sitegeist\PaperTiger\Helper\PaperTigerHelper;

class HelperTest extends TestCase
{

protected PaperTigerHelper $helper;

public function setUp(): void
{
$this->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));
}
}