/** * Listens to the 'view.cache.filter_content' event to decorate a chunk of HTML with cache information. * * Added info about linked tags * * @param sfEvent $event A sfEvent instance * @param string $content The HTML content * * @return string The decorated HTML string */ public function decorateContentWithDebug(sfEvent $event, $content) { $updatedContent = parent::decorateContentWithDebug($event, $content); if ($content === $updatedContent) { return $content; } $cacheMetadata = new CacheMetadata($this->getCache()->get($this->generateCacheKey($event['uri']))); if (null === $cacheMetadata->getData()) { return $content; } $tags = $cacheMetadata->getTags(); ksort($tags, SORT_ASC); $tagsCount = count($tags); $tagsContent = sprintf('[cache tags] count: %d', $tagsCount); if (0 != $tagsCount) { $tagsContent .= ', tags:'; foreach ($tags as $name => $version) { $tagsContent .= sprintf(' <span title="%s">%s</span>,', htmlspecialchars($version, ENT_QUOTES, sfConfig::get('sf_charset')), htmlspecialchars($name, ENT_QUOTES, sfConfig::get('sf_charset'))); } $tagsContent = substr($tagsContent, 0, -1) . '.'; } $textToReplace = ' <br /> '; return str_replace($textToReplace, $tagsContent, $updatedContent); }