Neos\Fusion\Core\Cache\CacheSegmentParser::getCacheSegments PHP Method

getCacheSegments() public method

Returns an array with extracted content segments, including the type (if they can be cached or not) and tags to be used for their entries when the segments are stored in a persistent cache.
public getCacheSegments ( ) : array
return array
    public function getCacheSegments()
    {
        return $this->cacheEntries;
    }

Usage Example

コード例 #1
0
 /**
  * Takes a string of content which includes cache segment markers, extracts the marked segments, writes those
  * segments which can be cached to the actual cache and returns the cleaned up original content without markers.
  *
  * This method is called by the TypoScript Runtime while rendering a TypoScript object.
  *
  * @param string $content The content with an outer cache segment
  * @param boolean $storeCacheEntries Whether to store extracted cache segments in the cache
  * @return string The (pure) content without cache segment markers
  */
 public function processCacheSegments($content, $storeCacheEntries = true)
 {
     $this->parser->extractRenderedSegments($content, $this->randomCacheMarker);
     if ($storeCacheEntries) {
         $segments = $this->parser->getCacheSegments();
         foreach ($segments as $segment) {
             $metadata = explode(';', $segment['metadata']);
             $tagsValue = $metadata[0] === '' ? [] : ($metadata[0] === '*' ? false : explode(',', $metadata[0]));
             // FALSE means we do not need to store the cache entry again (because it was previously fetched)
             if ($tagsValue !== false) {
                 $lifetime = isset($metadata[1]) ? (int) $metadata[1] : null;
                 $this->cache->set($segment['identifier'], $segment['content'], $this->sanitizeTags($tagsValue), $lifetime);
             }
         }
     }
     return $this->parser->getOutput();
 }
All Usage Examples Of Neos\Fusion\Core\Cache\CacheSegmentParser::getCacheSegments