/**
  * 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();
 }
 /**
  * @test
  */
 public function getCacheSegmentsAfterExtractWithUncachedSegmentsReturnsContentWithPlaceholder()
 {
     $parser = new CacheSegmentParser();
     $parser->extractRenderedSegments($this->contentWithUncachedSegments);
     $entries = $parser->getCacheSegments();
     $this->assertEquals($this->expectedEntriesWithUncachedSegments, $entries);
 }