Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Include Allow third-party fusion code for fusion forms #21

Merged
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
18 changes: 11 additions & 7 deletions Classes/FusionFormRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ class FusionFormRenderer implements RendererInterface
*/
protected $packageManager;

/**
* @Flow\InjectConfiguration(path="fusionAutoInclude")
* @var array
*/
protected $packagesForFusionAutoInclude;

public function setControllerContext(ControllerContext $controllerContext)
{
$this->controllerContext = $controllerContext;
Expand Down Expand Up @@ -88,14 +94,12 @@ public function renderRenderable(RootRenderableInterface $formRuntime): string

$fusionView = new FusionView();
$fusionView->setControllerContext($this->controllerContext);
$fusionView->disableFallbackView();
$fusionView->setPackageKey('Neos.Form.FusionRenderer');
$fusionView->setFusionPathPatterns([
$this->packageManager->getPackage('Neos.Fusion')->getResourcesPath() . 'Private/Fusion',
$this->packageManager->getPackage('Neos.Form.FusionRenderer')->getResourcesPath() . 'Private/Fusion/Core',
$this->packageManager->getPackage('Neos.Form.FusionRenderer')->getResourcesPath() . 'Private/Fusion/ContainerElements',
$this->packageManager->getPackage('Neos.Form.FusionRenderer')->getResourcesPath() . 'Private/Fusion/Elements',
]);

$fusionView->setFusionPathPatterns(array_map(function (string $value) {
return $this->packageManager->getPackage($value)->getResourcesPath() . 'Private/Fusion';
}, array_keys(array_filter($this->packagesForFusionAutoInclude))));

$fusionView->setFusionPath('neos_form');
$fusionView->assign('formRuntime', $formRuntime);
return $fusionView->render();
Expand Down
5 changes: 5 additions & 0 deletions Configuration/Settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ Neos:
'Neos.Form:Form':
rendererClassName: 'Neos\Form\FusionRenderer\FusionFormRenderer'

FusionRenderer:
fusionAutoInclude:
'Neos.Fusion': true
'Neos.Form.FusionRenderer': true

Neos:
fusion:
autoInclude:
Expand Down
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,19 @@ Trying to render it, however, will lead to an exception:
The Fusion object `Your.Package:EmailAddress` is not completely defined (missing property `@class`). Most likely you didn't inherit from a basic object.
```

Let's change this by defining the Fusion object:
Let's change this.

First configure FusionRenderer to include your custom Fusion code:

```yaml
Neos:
Form:
FusionRenderer:
fusionAutoInclude:
'Your.Package': true
```

then define the rendering in your own fusion:

*EmailAddressFormElement.fusion*:

Expand Down