Skip to content

Commit

Permalink
FEATURE: Allow FileUpload "resourceCollection" to be configured
Browse files Browse the repository at this point in the history
  • Loading branch information
bwaidelich committed Jun 16, 2020
1 parent 4e6cf76 commit a0d1a9c
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Classes/NodeType/ResourceCollectionsPostprocessor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
namespace Neos\Form\Builder\NodeType;

use Neos\ContentRepository\Domain\Model\NodeType;
use Neos\ContentRepository\NodeTypePostprocessor\NodeTypePostprocessorInterface;
use Neos\Flow\Annotations as Flow;

/**
* Node Type post processor that populates the "resourceCollection" property with all configured resource collections
*/
class ResourceCollectionsPostprocessor implements NodeTypePostprocessorInterface
{

/**
* @Flow\InjectConfiguration(package="Neos.Flow", path="resource.collections")
* @var array
*/
protected $resourceCollectionSettings;

public function process(NodeType $nodeType, array &$configuration, array $options)
{
$resourceCollectionOptions = [];
foreach ($this->resourceCollectionSettings as $collectionName => $_) {
$resourceCollectionOptions[] = [
'value' => $collectionName,
'label' => $collectionName,
];
}
$configuration['properties']['resourceCollection']['ui']['inspector']['editorOptions']['values'] = $resourceCollectionOptions;
}
}
10 changes: 10 additions & 0 deletions Configuration/NodeTypes.FormElements.FileUpload.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
superTypes:
'Neos.Form.Builder:FormElement': TRUE
'Neos.Form.Builder:DefaultValueMixin': FALSE
postprocessors:
'Neos.Form.Builder:ResourceCollectionsPostprocessor':
postprocessor: 'Neos\Form\Builder\NodeType\ResourceCollectionsPostprocessor'
ui:
label: 'File upload'
icon: 'icon-upload'
Expand Down Expand Up @@ -42,3 +45,10 @@
'csv':
label: '.csv'
icon: 'icon-file-text'
'resourceCollection':
type: string
ui:
label: i18n
inspector:
group: 'formElement'
editor: 'Neos.Neos/Inspector/Editors/SelectBoxEditor'
3 changes: 3 additions & 0 deletions Resources/Private/Translations/de/NodeTypes/FileUpload.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
<trans-unit id="properties.allowedExtensions" xml:space="preserve">
<source>Allowed file types</source>
<target xml:lang="de" state="translated">Erlaubte Dateitypen</target></trans-unit>
<trans-unit id="properties.resourceCollection" xml:space="preserve">
<source>Target Resource Collection</source>
<target xml:lang="de" state="translated">Ziel "Resource Collection"</target></trans-unit>
</body>
</file>
</xliff>
3 changes: 3 additions & 0 deletions Resources/Private/Translations/en/NodeTypes/FileUpload.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
<trans-unit id="properties.allowedExtensions" xml:space="preserve">
<source>Allowed file types</source>
</trans-unit>
<trans-unit id="properties.resourceCollection" xml:space="preserve">
<source>Target Resource Collection</source>
</trans-unit>
</body>
</file>
</xliff>

0 comments on commit a0d1a9c

Please sign in to comment.