public function render($name, $useRawKeys = false)
{
if (false === strpos($name, '.')) {
if (true === $this->templateVariableContainer->exists($name)) {
return $this->templateVariableContainer->get($name);
}
} else {
$segments = explode('.', $name);
$lastSegment = array_shift($segments);
$templateVariableRootName = $lastSegment;
if (true === $this->templateVariableContainer->exists($templateVariableRootName)) {
$templateVariableRoot = $this->templateVariableContainer->get($templateVariableRootName);
if (true === $useRawKeys) {
return ObjectAccess::getPropertyPath($templateVariableRoot, implode('.', $segments));
}
try {
$value = $templateVariableRoot;
foreach ($segments as $segment) {
if (true === ctype_digit($segment)) {
$segment = intval($segment);
$index = 0;
// Note: this loop approach is not a stupid solution. If you doubt this,
// attempt to feth a number at a numeric index from ObjectStorage ;)
foreach ($value as $possibleValue) {
if ($index === $segment) {
$value = $possibleValue;
break;
}
++$index;
}
continue;
}
$value = ObjectAccess::getProperty($value, $segment);
}
return $value;
} catch (\Exception $e) {
return null;
}
}
}
return null;
}