FluidTYPO3\Vhs\ViewHelpers\Render\CacheViewHelper::render PHP Method

render() public method

Render
public render ( mixed $identity, mixed $content = null ) : mixed
$identity mixed Identifier for the cached content (usage preferred)
$content mixed Value to be cached
return mixed
    public function render($identity, $content = null)
    {
        if (false === ctype_alnum(preg_replace('/[\\-_]/i', '', $identity))) {
            if (true === $identity instanceof DomainObjectInterface) {
                $identity = get_class($identity) . self::ID_SEPARATOR . $identity->getUid();
            } elseif (true === method_exists($identity, '__toString')) {
                $identity = (string) $identity;
            } else {
                throw new \RuntimeException('Parameter $identity for Render/CacheViewHelper was not a string or a string-convertible object', 1352581782);
            }
        }
        // Hash the cache-key to circumvent disallowed chars
        $identity = sha1($identity);
        if (true === $this->has($identity)) {
            return $this->retrieve($identity);
        }
        if (null === $content) {
            $content = $this->renderChildren();
        }
        $this->store($content, $identity);
        return $content;
    }