Автор: Dmitry Dulepov (dmitry.dulepov@gmail.com)
Наследование: implements TYPO3\CMS\Core\SingletonInterface
Пример #1
0
 /**
  * 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');
 }
Пример #2
0
 /**
  * Returns the cache to use.
  *
  * @return CacheInterface
  */
 public function getCache()
 {
     if (TYPO3_MODE !== 'FE' || is_object($GLOBALS['BE_USER']) || ConfigurationReader::getInstance()->get('cache/disable')) {
         $cache = GeneralUtility::makeInstance('DmitryDulepov\\Realurl\\Cache\\NullCache');
     } else {
         $cache = CacheFactory::getCache();
     }
     return $cache;
 }
Пример #3
0
 /**
  * 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;
 }
Пример #4
0
 /**
  * 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);
 }