Neos\Fusion\Core\Cache\ContentCache::replaceCachePlaceholders PHP Méthode

replaceCachePlaceholders() protected méthode

Find cache placeholders in a cached segment and return the identifiers
protected replaceCachePlaceholders ( string &$content, boolean $addCacheSegmentMarkersToPlaceholders ) : integer | boolean
$content string
$addCacheSegmentMarkersToPlaceholders boolean
Résultat integer | boolean Number of replaced placeholders or FALSE if a placeholder couldn't be found
    protected function replaceCachePlaceholders(&$content, $addCacheSegmentMarkersToPlaceholders)
    {
        $cache = $this->cache;
        $foundMissingIdentifier = false;
        $content = preg_replace_callback(self::CACHE_PLACEHOLDER_REGEX, function ($match) use($cache, &$foundMissingIdentifier, $addCacheSegmentMarkersToPlaceholders) {
            $identifier = $match['identifier'];
            $entry = $cache->get($identifier);
            if ($entry !== false) {
                if ($addCacheSegmentMarkersToPlaceholders) {
                    return ContentCache::CACHE_SEGMENT_START_TOKEN . $this->randomCacheMarker . $identifier . ContentCache::CACHE_SEGMENT_SEPARATOR_TOKEN . $this->randomCacheMarker . '*' . ContentCache::CACHE_SEGMENT_SEPARATOR_TOKEN . $this->randomCacheMarker . $entry . ContentCache::CACHE_SEGMENT_END_TOKEN . $this->randomCacheMarker;
                } else {
                    return $entry;
                }
            } else {
                $foundMissingIdentifier = true;
                return '';
            }
        }, $content, -1, $count);
        if ($foundMissingIdentifier) {
            return false;
        }
        return $count;
    }