parsedMarkup = $obj->parseMarkup(); } return $obj; } /** * Initializes the object properties from the cached data. * @param array $cached The cached data array. */ protected function initFromCache($cached) { parent::initFromCache($cached); $this->parsedMarkup = array_key_exists('parsed-markup', $cached) ? $cached['parsed-markup'] : $this->parseMarkup($this->markup); } /** * Initializes a cache item. * @param array &$item The cached item array. */ protected function initCacheItem(&$item) { parent::initCacheItem($item); $item['parsed-markup'] = $this->parsedMarkup; } protected function parseMarkup() { $extension = strtolower(File::extension($this->fileName)); switch ($extension) { case 'txt': $result = htmlspecialchars($this->markup); break; case 'md': $result = Markdown::parse($this->markup); break; default: $result = $this->markup; } return $result; } }