Skip to content

Commit cb072e9

Browse files
authoredDec 20, 2023
Merge pull request #2 from Garagist/feature_contextProperties
Pass more context properties to ContentBox
2 parents 5e5473c + 7869883 commit cb072e9

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed
 

‎Classes/Service/FusionService.php

+8-11
Original file line numberDiff line numberDiff line change
@@ -50,31 +50,28 @@ class FusionService
5050
/**
5151
* Render the given string of AFX and returns it
5252
*
53-
* @param TraversableNodeInterface[] $contextNodes
53+
* @param array $contextProperties
5454
* @param string $html
5555
* @param string|null $props
5656
* @return string
5757
* @throws ContentBoxRenderingException|AfxParserException
5858
*/
59-
public function render(array $contextNodes, string $html, ?string $props = null): string
59+
public function render(array $contextProperties, string $html, ?string $props = null): string
6060
{
6161
$props = isset($props) ? Yaml::parse($props) : [];
6262
$controllerContext = $this->createDummyControllerContext();
6363

6464
try {
6565
$fusion = AfxService::convertAfxToFusion($html);
66-
$parsedFusion = $this->parseFusionSourceCode('html = ' . $fusion, $contextNodes['site'] ?? null);
66+
$parsedFusion = $this->parseFusionSourceCode('html = ' . $fusion, $contextProperties['site'] ?? null);
6767

6868
$fusionRuntime = $this->fusionRuntimeFactory->createFromConfiguration($parsedFusion, $controllerContext);
6969
$fusionRuntime->pushContext('props', $props);
70-
if (isset($contextNodes['node'])) {
71-
$fusionRuntime->pushContext('node', $contextNodes['node']);
72-
}
73-
if (isset($contextNodes['documentNode'])) {
74-
$fusionRuntime->pushContext('documentNode', $contextNodes['documentNode']);
75-
}
76-
if (isset($contextNodes['site'])) {
77-
$fusionRuntime->pushContext('site', $contextNodes['site']);
70+
71+
foreach ($contextProperties as $key => $value) {
72+
if ($value) {
73+
$fusionRuntime->pushContext($key, $value);
74+
}
7875
}
7976
$fusionRuntime->setEnableContentCache(false);
8077
return $fusionRuntime->render('html');

0 commit comments

Comments
 (0)
Please sign in to comment.