CacheSegmentParser
class CacheSegmentParser (View source)
A parser which extracts cache segments by searching for start and end markers in the given content.
Properties
protected string | $randomCacheMarker | ||
protected int | $randomCacheMarkerLength | ||
protected string | $output | ||
protected string | $outerSegmentContent | ||
protected array | $cacheSegments | ||
protected int | $uncachedPartCount | ||
protected string | $content |
Methods
Parses the given content and extracts segments by searching for start end end markers. Those segments can later be retrieved via getCacheSegments() and stored in a cache.
Parses a segment at current position diving down into nested segments.
No description
Make sure that we keep only necessary information for caching and strip all internal segment data.
No description
Calculates a position assuming that the given position is a token followed by the random cache marker
Find the next position of the given token (one of the ContentCache::CACHESEGMENT*_TOKEN constants) in the parsed content.
Returns the fully intact content as originally given to extractRenderedSegments() but without the markers. This content is suitable for being used as output for the user.
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.
No description
No description
Details
__construct(string $content, string $randomCacheMarker = '')
Parses the given content and extracts segments by searching for start end end markers. Those segments can later be retrieved via getCacheSegments() and stored in a cache.
This method also prepares a cleaned up output which can be retrieved later. See getOutput() for more information.
protected array
parseSegment(int $currentPosition)
Parses a segment at current position diving down into nested segments.
The returned segmentData array has the following keys:
- identifier -> The identifier of this entry for cached segments (or the eval expression for everything else)
- type -> The type of segment (one of the ContentCache::SEGMENTTYPE* constants)
- context -> eventual context information saved for a cached segment (optional)
- metadata -> cache entry metadata like tags
- content -> the content of this segment including embed code for sub segments
- cleanContent -> the raw content without any cache references for this segment and all sub segments
- embed -> the placeholder content for this segment to be used in "content" of parent segments
protected array
extractContentAndSubSegments(int $currentPosition, array $segmentData)
No description
protected array
reduceSegmentDataToCacheRelevantInformation(array $segmentData)
Make sure that we keep only necessary information for caching and strip all internal segment data.
protected string
extractContent(int $fromPosition, int $toPosition = null)
No description
protected int
calculateCurrentPosition(int $position)
Calculates a position assuming that the given position is a token followed by the random cache marker
protected int|bool
calculateNextTokenPosition(int $currentPosition, string $token)
Find the next position of the given token (one of the ContentCache::CACHESEGMENT*_TOKEN constants) in the parsed content.
string
getOutput()
Returns the fully intact content as originally given to extractRenderedSegments() but without the markers. This content is suitable for being used as output for the user.
array
getCacheSegments()
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.
int
getUncachedPartCount()
No description
string
getOuterSegmentContent()
No description