Skip to content

Commit

Permalink
TASK: Configure addtitional form prototypes via settings
Browse files Browse the repository at this point in the history
  • Loading branch information
mficzel committed Jan 16, 2023
1 parent b7f6597 commit 15725b7
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
10 changes: 7 additions & 3 deletions Classes/Controller/ModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ class ModuleController extends ActionController

/**
* @var array
* @Flow\InjectConfiguration(path="backendModule.fusionPathPatterns")
* @Flow\InjectConfiguration(path="backendModule.additionalFusionIncludePathes")
*/
protected $fusionPathPatterns;
protected $additionalFusionIncludePathes;

/**
* @var string
Expand Down Expand Up @@ -107,7 +107,11 @@ class ModuleController extends ActionController
*/
public function initializeView(ViewInterface $view)
{
$this->view->setFusionPathPatterns($this->fusionPathPatterns);
$fusionPathes = ['resource://Sitegeist.Taxonomy/Private/Fusion/Backend'];
if ($this->additionalFusionIncludePathes && is_array($this->additionalFusionIncludePathes)) {
$fusionPathes = Arrays::arrayMergeRecursiveOverrule($fusionPathes, $this->additionalFusionIncludePathes);
}
$this->view->setFusionPathPatterns($fusionPathes);
$this->view->assign('contentDimensionOptions', $this->getContentDimensionOptions());
}

Expand Down
8 changes: 6 additions & 2 deletions Configuration/Settings.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
Sitegeist:
Taxonomy:
backendModule:
fusionPathPatterns:
Sitegeist.Taxonomy: 'resource://Sitegeist.Taxonomy/Private/Fusion/Backend'
# fusion files or folders that are to be included in the backend module
additionalFusionIncludePathes: []
# names of additional prototypes to be rendered in vocabulary forms
additionalVocabularyFieldPrototypes: []
# names of additional prototypes to be rendered in taxonomy forms
additionalTaxonomyFieldPrototypes: []

contentRepository:
rootNodeName: 'taxonomies'
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,10 @@ Packages can add additional fields to the forms of taxonomies and vocabularies.
the following steps are required.

1. Extend the NodeTypes `Sitegeist.Taxonomy:Taxonomy` or `Sitegeist.Taxonomy:Vocabulary` in your package.
2. Add tha path to your additional `Root.fusion` to the Setting in path `Sitegeist.Taxonomy.backendModule.fusionPathPatterns`.
3. In the fusion code define each field as prototype that accepts the props `taxon` & `defaultTaxon` resp. `vocabulary` & `defaultVocabulary`.
4. Register those prototypesNames by adding them to the property `additionalFieldPrototypeNames` of the prototype `Sitegeist.Taxonomy:Form.Taxonomy` or `Sitegeist.Taxonomy:Form.Vocabulary`
2. Add tha path to your additional `Root.fusion` to the Setting in path `Sitegeist.Taxonomy.backendModule.additionalFusionIncludePathes`.
3. In the fusion code define each field as prototype that accepts the props `name` plus `taxon` & `defaultTaxon` resp. `vocabulary` & `defaultVocabulary`.
4. Register addtional prototypesNames by adding them to the Settings `Sitegeist.Taxonomy.backendModule.additionalVocabularyFieldPrototypes` or
`Sitegeist.Taxonomy.backendModule.additionalTaxonomyFieldPrototypes`

## Contribution

Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/Fusion/Backend/Form/Taxonomy.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ prototype(Sitegeist.Taxonomy:Form.Taxonomy) < prototype(Neos.Fusion:Component) {
parent = null
vocabulary = null

additionalFieldPrototypeNames = Neos.Fusion:DataStructure
additionalFieldPrototypeNames = ${Configuration.setting('Sitegeist.Taxonomy.backendModule.additionalTaxonomyFieldPrototypes')}

renderer = afx`
<Neos.Fusion.Form:Form form.target.action={props.targetAction} form.data.properties={props.taxonomy.properties}>
Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/Fusion/Backend/Form/Vocabulary.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ prototype(Sitegeist.Taxonomy:Form.Vocabulary) < prototype(Neos.Fusion:Component)
defaultVocabulary = null
taxonomyRoot = null

additionalFieldPrototypeNames = Neos.Fusion:DataStructure
additionalFieldPrototypeNames = ${Configuration.setting('Sitegeist.Taxonomy.backendModule.additionalVocabularyFieldPrototypes')}

renderer = afx`
<Neos.Fusion.Form:Form form.target.action={props.targetAction} form.data.properties={props.vocabulary ? props.vocabulary.properties : null}>
Expand Down

0 comments on commit 15725b7

Please sign in to comment.