/** * @param string $text * @param boolean $trim * @param boolean $htmlentities * @throws Exception * @return string */ public function render($text = null, $trim = true, $htmlentities = false) { if (null === $text) { $text = $this->renderChildren(); } if (null === $text) { return null; } $cacheIdentifier = sha1($text); if (true === $this->cache->has($cacheIdentifier)) { return $this->cache->get($cacheIdentifier); } $this->markdownExecutablePath = CommandUtility::getCommand('markdown'); if (false === is_executable($this->markdownExecutablePath)) { throw new Exception('Use of Markdown requires the "markdown" shell utility to be installed and accessible; this binary ' . 'could not be found in any of your configured paths available to this script', 1350511561); } if (true === (bool) $trim) { $text = trim($text); } if (true === (bool) $htmlentities) { $text = htmlentities($text); } $transformed = $this->transform($text); $this->cache->set($cacheIdentifier, $transformed); return $transformed; }
/** * @param string $id * @return mixed */ protected function retrieve($id) { if ($this->cache->has(self::ID_PREFIX . self::ID_SEPARATOR . $id)) { return $this->cache->get(self::ID_PREFIX . self::ID_SEPARATOR . $id); } return NULL; }
/** * @param string $id * @return mixed */ protected function retrieve($id) { if ($this->cache->has(get_class($this) . self::ID_SEPARATOR . $id)) { return $this->cache->get(get_class($this) . self::ID_SEPARATOR . $id); } return NULL; }
/** * @param string $text * @param boolean $trim * @param boolean $htmlentities * @throws Exception * @return string */ public function render($text = NULL, $trim = TRUE, $htmlentities = FALSE) { if (NULL === $text) { $text = $this->renderChildren(); } if (NULL === $text) { return NULL; } $cacheIdentifier = sha1($text); if (TRUE === $this->cache->has($cacheIdentifier)) { return $this->cache->get($cacheIdentifier); } $this->markdownExecutablePath = \TYPO3\CMS\Core\Utility\CommandUtility::getCommand('markdown'); if (FALSE === is_executable($this->markdownExecutablePath)) { throw new Exception('Use of Markdown requires the "markdown" shell utility to be installed ' . 'and accessible; this binary could not be found in any of your configured paths available to this script', 1350511561); } if (TRUE === (bool) $trim) { $text = trim($text); } if (TRUE === (bool) $htmlentities) { $text = htmlentities($text); } $transformed = $this->transform($text); $this->cache->set($cacheIdentifier, $transformed); return $transformed; }
/** * Transfers all entries from the early class information cache to * the classes cache in order to make them persistent * * @return void */ protected function transferRuntimeClassInformationCacheEntriesToClassesCache() { foreach ($this->runtimeClassLoadingInformationCache as $classLoadingInformation) { $cacheEntryIdentifier = strtolower(str_replace('\\', '_', $classLoadingInformation[1])); if (!$this->classesCache->has($cacheEntryIdentifier)) { $this->classesCache->set($cacheEntryIdentifier, implode("ÿ", $classLoadingInformation)); } } }
/** * Returns parsed data from a given file and language key. * * @param string $fileReference Input is a file-reference (see t3lib_div::getFileAbsFileName). That file is expected to be a supported locallang file format * @param string $languageKey Language key * @param string $charset Character set (option); if not set, determined by the language key * @param integer $errorMode Error mode (when file could not be found): 0 - syslog entry, 1 - do nothing, 2 - throw an exception$ * @param boolean $isLocalizationOverride TRUE if $fileReference is a localization override * @return array|boolean */ public function getParsedData($fileReference, $languageKey, $charset, $errorMode, $isLocalizationOverride = FALSE) { try { $hash = md5($fileReference . $languageKey . $charset); $this->errorMode = $errorMode; // English is the default language $languageKey = $languageKey === 'en' ? 'default' : $languageKey; // Check if the default language is processed before processing other language if (!$this->store->hasData($fileReference, 'default') && $languageKey !== 'default') { $this->getParsedData($fileReference, 'default', $charset, $this->errorMode); } // If the content is parsed (local cache), use it if ($this->store->hasData($fileReference, $languageKey)) { return $this->store->getData($fileReference); } // If the content is in cache (system cache), use it if ($this->cacheInstance->has($hash)) { // Load data from the caching framework $this->store->setData($fileReference, $languageKey, $this->cacheInstance->get($hash)); return $this->store->getData($fileReference, $languageKey); } $this->store->setConfiguration($fileReference, $languageKey, $charset); /** @var $parser \TYPO3\CMS\Core\Localization\Parser\LocalizationParserInterface */ $parser = $this->store->getParserInstance($fileReference); // Get parsed data $LOCAL_LANG = $parser->getParsedData($this->store->getAbsoluteFileReference($fileReference), $languageKey, $charset); // Override localization if (!$isLocalizationOverride && isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride'])) { $this->localizationOverride($fileReference, $languageKey, $charset, $errorMode, $LOCAL_LANG); } // Save parsed data in cache $this->store->setData($fileReference, $languageKey, $LOCAL_LANG[$languageKey]); // Cache processed data $this->cacheInstance->set($hash, $this->store->getDataByLanguage($fileReference, $languageKey)); } catch (\TYPO3\CMS\Core\Localization\Exception\FileNotFoundException $exception) { // Source localization file not found $this->store->setData($fileReference, $languageKey, array()); } return $this->store->getData($fileReference); }