Skip to content

Commit 5d58f31

Browse files
authored
Merge pull request #3 from Garagist/feature/context_properties_v1
Pass more context properties to ContentBox
2 parents 06319bf + 76ff201 commit 5d58f31

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

Classes/Service/FusionService.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,31 +35,28 @@ class FusionService extends NeosFusionService
3535
/**
3636
* Render the given string of AFX and returns it
3737
*
38-
* @param [NodeInterface] $contextNodes
38+
* @param array $contextProperties
3939
* @param string $html
4040
* @param string|null $props
4141
* @return string
4242
* @throws ContentBoxRenderingException|AfxParserException
4343
*/
44-
public function render(array $contextNodes, string $html, ?string $props = null): string
44+
public function render(array $contextProperties, string $html, ?string $props = null): string
4545
{
4646
$props = isset($props) ? Yaml::parse($props) : [];
4747
$controllerContext = $this->createDummyControllerContext();
4848

4949
try {
5050
$fusion = AfxService::convertAfxToFusion($html);
51-
$parsedFusion = $this->getMergedFusionObjectTree('html = ' . $fusion, $contextNodes['site'] ?? null);
51+
$parsedFusion = $this->getMergedFusionObjectTree('html = ' . $fusion, $contextProperties['site'] ?? null);
5252

5353
$fusionRuntime = $this->fusionRuntimeFactory->create($parsedFusion, $controllerContext);
5454
$fusionRuntime->pushContext('props', $props);
55-
if (isset($contextNodes['node'])) {
56-
$fusionRuntime->pushContext('node', $contextNodes['node']);
57-
}
58-
if (isset($contextNodes['documentNode'])) {
59-
$fusionRuntime->pushContext('documentNode', $contextNodes['documentNode']);
60-
}
61-
if (isset($contextNodes['site'])) {
62-
$fusionRuntime->pushContext('site', $contextNodes['site']);
55+
56+
foreach ($contextProperties as $key => $value) {
57+
if ($value) {
58+
$fusionRuntime->pushContext($key, $value);
59+
}
6360
}
6461
$fusionRuntime->setEnableContentCache(false);
6562

0 commit comments

Comments
 (0)