Cachearium\CacheAbstract::recursiveEnd PHP Method

recursiveEnd() public method

public recursiveEnd ( boolean $print = true ) : string
$print boolean
return string The string. If $print == true the string is printed as well.
    public function recursiveEnd($print = true)
    {
        // @codeCoverageIgnoreStart
        if (!$this->enabled) {
            return '';
        }
        // @codeCoverageIgnoreEnd
        $data = ob_get_clean();
        /* @var $cachedata CacheData */
        $cachedata = $this->loopdata[$this->inloop];
        $cachedata->appendData($data);
        try {
            $cachedata->generateDependenciesHash($this);
        } catch (\Cachearium\Exceptions\CacheUnsupportedOperation $e) {
            // not much we can do here, so just keep on going
        }
        $mainkey = $this->keyFromDeps($cachedata->getKey(), $cachedata->dependencies);
        if (!$this->storeP($cachedata, 'cacherecursive', 0, $mainkey)) {
            throw new \Cachearium\Exceptions\CacheStoreFailure("Storing key");
        }
        if (!$this->storeData($cachedata)) {
            throw new \Cachearium\Exceptions\CacheStoreFailure("Storing data");
        }
        // if recursive
        unset($this->loopdata[$this->inloop]);
        $this->inloop--;
        if ($this->inloop > 0) {
            return '';
        }
        if ($print) {
            $key = "cache-" . rand();
            // @codeCoverageIgnoreStart
            if (static::$debugOnPage) {
                $this->printProbeStart($key, $cachedata, 'save');
            }
            // @codeCoverageIgnoreEnd
            $str = $cachedata->stringify($this);
            echo $str;
            // @codeCoverageIgnoreStart
            if (static::$debugOnPage) {
                $this->printProbeEnd($key, $cachedata);
            }
            // @codeCoverageIgnoreEnd
            return $str;
        }
        return $cachedata->stringify($this);
    }