/** * Initializes the instance. * * @throws \Exception */ protected function initialize() { $this->initializeConfiguration(); $this->emptySegmentValue = $this->configuration->get('init/emptySegmentValue'); $this->rootPageId = (int) $this->configuration->get('pagePath/rootpage_id'); $this->utility = GeneralUtility::makeInstance('DmitryDulepov\\Realurl\\Utility', $this->configuration); $this->cache = $this->utility->getCache(); $this->separatorCharacter = $this->configuration->get('pagePath/spaceCharacter'); }
/** * Returns the cache to use. * * @return CacheInterface */ public function getCache() { if (TYPO3_MODE !== 'FE' || is_object($GLOBALS['BE_USER']) || $this->configuration->get('cache/disable')) { $cache = GeneralUtility::makeInstance('DmitryDulepov\\Realurl\\Cache\\NullCache'); } else { $cache = CacheFactory::getCache(); } return $cache; }
/** * Removes ignored parameters from the query string. * * @param string $queryString * @return string */ protected function removeIgnoredParametersFromQueryString($queryString) { if ($queryString) { $ignoredParametersRegExp = $this->configuration->get('cache/ignoredGetParametersRegExp'); if ($ignoredParametersRegExp) { $collectedParameters = array(); foreach (explode('&', trim($queryString, '&')) as $parameterPair) { list($parameterName, $parameterValue) = explode('=', $parameterPair, 2); if ($parameterName !== '') { $parameterName = urldecode($parameterName); if (preg_match($ignoredParametersRegExp, $parameterName)) { $this->ignoredUrlParameters[$parameterName] = $parameterValue; } else { $collectedParameters[$parameterName] = urldecode($parameterValue); } } } $queryString = $this->createQueryStringFromParameters($collectedParameters); } } return $queryString; }
/** * Checks if the URL can be cached. This function may prevent RealURL cache * pollution with Solr or Indexed search URLs. * * @param string $url * @return bool */ protected function canCacheUrl($url) { $bannedUrlsRegExp = $this->configuration->get('cache/banUrlsRegExp'); return !$bannedUrlsRegExp || !preg_match($bannedUrlsRegExp, $url); }