FluidTYPO3\Vhs\ViewHelpers\Variable\GetViewHelper::render PHP Method

render() public method

public render ( string $name, boolean $useRawKeys = false ) : mixed
$name string
$useRawKeys boolean
return mixed
    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;
    }
GetViewHelper