Skip to content

Instantly share code, notes, and snippets.

@bwaidelich
Created June 21, 2022 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bwaidelich/f73d331b8edad8e84f599675f2fdf4e7 to your computer and use it in GitHub Desktop.
Save bwaidelich/f73d331b8edad8e84f599675f2fdf4e7 to your computer and use it in GitHub Desktop.
Neos CMS: Fusion based Zip Archive (example structure)
<Some.Package:ZipArchiveLink zip.files={['resource://Neos.Neos/Public/Images/Login/Logo.svg', 'resource://Neos.Neos/Public/Images/Login/Wallpaper.jpg']} filename="archive.zip">
Download
</Some.Package:ZipArchiveLink>
prototype(Some.Package:ZipArchiveUri) {
@class = 'Some\\Package\\ZipArchiveUriImplementation'
files = ${[]}
}
prototype(Some.Package:ZipArchiveLink) < prototype(Neos.Fusion:Component) {
filename = ''
content = ''
attributes = Neos.Fusion:DataStructure
zip = Some.Package:ZipArchiveUri
renderer = afx`<a href={props.zip} download={props.filename} {...props.attributes}>{props.content}</a>`
}
<?php
declare(strict_types=1);
namespace Some\Package;
use Neos\Fusion\FusionObjects\AbstractFusionObject;
final class ZipArchiveUriImplementation extends AbstractFusionObject
{
public function evaluate()
{
foreach ($this->fusionValue('files') as $filePathAndName) {
// your zip archive logic here
}
return '/path/to/generated/archive.zip';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment