/**
* {@inheritdoc}
*
* @return string
*/
public function evaluate()
{
$actionRequest = $this->tsRuntime->getControllerContext()->getRequest();
if (!$actionRequest instanceof ActionRequest) {
$actionRequest = null;
}
$fluidTemplate = new Helpers\FluidView($this, $actionRequest);
$templatePath = $this->getTemplatePath();
if ($templatePath === null) {
throw new \Exception(sprintf("\n\t\t\t\tNo template path set.\n\t\t\t\tMost likely you didn't configure `templatePath` in your TypoScript object correctly.\n\t\t\t\tFor example you could add and adapt the following line to your TypoScript:\n\t\t\t\t`prototype(%s) < prototype(Neos.Fusion:Template) {\n\t\t\t\t\ttemplatePath = 'resource://Vendor.Package/Private/Templates/MyObject.html'\n\t\t\t\t}`\n\t\t\t", $templatePath, $this->typoScriptObjectName));
}
$fluidTemplate->setTemplatePathAndFilename($templatePath);
$partialRootPath = $this->getPartialRootPath();
if ($partialRootPath !== null) {
$fluidTemplate->setPartialRootPath($partialRootPath);
}
$layoutRootPath = $this->getLayoutRootPath();
if ($layoutRootPath !== null) {
$fluidTemplate->setLayoutRootPath($layoutRootPath);
}
// Template resources need to be evaluated from the templates package not the requests package.
if (strpos($templatePath, 'resource://') === 0) {
$templateResourcePathParts = parse_url($templatePath);
$fluidTemplate->setResourcePackage($templateResourcePathParts['host']);
}
foreach ($this->properties as $key => $value) {
if (in_array($key, $this->ignoreProperties)) {
continue;
}
if (!is_array($value)) {
// if a value is a SIMPLE TYPE, e.g. neither an Eel expression nor a TypoScript object,
// we can just evaluate it (to handle processors) and then assign it to the template.
$evaluatedValue = $this->tsValue($key);
$fluidTemplate->assign($key, $evaluatedValue);
} else {
// It is an array; so we need to create a "proxy" for lazy evaluation, as it could be a
// nested TypoScript object, Eel expression or simple value.
$fluidTemplate->assign($key, new Helpers\FusionPathProxy($this, $this->path . '/' . $key, $value));
}
}
$this->initializeView($fluidTemplate);
$sectionName = $this->getSectionName();
if ($sectionName !== null) {
return $fluidTemplate->renderSection($sectionName);
} else {
return $fluidTemplate->render();
}
}