‪TYPO3CMS  9.5
CanonicalizationUtility.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
3 
5 
6 /*
7  * This file is part of the TYPO3 CMS project.
8  *
9  * It is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License, either version 2
11  * of the License, or any later version.
12  *
13  * For the full copyright and license information, please read the
14  * LICENSE.txt file that was distributed with this source code.
15  *
16  * The TYPO3 project - inspiring people to share!
17  */
18 
19 use Psr\Http\Message\ServerRequestInterface;
23 
25 {
41  public static function ‪getParamsToExcludeForCanonicalizedUrl(int $pageId, array $additionalCanonicalizedUrlParameters = []): array
42  {
43  $cacheHashCalculator = GeneralUtility::makeInstance(CacheHashCalculator::class);
44 
45  $GET = (‪$GLOBALS['TYPO3_REQUEST'] instanceof ServerRequestInterface) ? ‪$GLOBALS['TYPO3_REQUEST']->getQueryParams() : [];
46  $GET['id'] = $pageId;
47 
48  $queryString = ‪HttpUtility::buildQueryString($GET, '&');
49  $cHashArray = $cacheHashCalculator->getRelevantParameters($queryString);
50 
51  // By exploding the earlier imploded array, we get the flat array with URL params
52  $urlParameters = GeneralUtility::explodeUrl2Array($queryString);
53 
54  $paramsToExclude = array_keys(
55  array_diff(
56  $urlParameters,
57  $cHashArray
58  )
59  );
60 
61  return array_diff($paramsToExclude, $additionalCanonicalizedUrlParameters);
62  }
63 }
‪TYPO3\CMS\Frontend\Utility
Definition: CanonicalizationUtility.php:4
‪TYPO3\CMS\Core\Utility\HttpUtility\buildQueryString
‪static string buildQueryString(array $parameters, string $prependCharacter='', bool $skipEmptyParameters=false)
Definition: HttpUtility.php:160
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Frontend\Page\CacheHashCalculator
Definition: CacheHashCalculator.php:24
‪TYPO3\CMS\Frontend\Utility\CanonicalizationUtility
Definition: CanonicalizationUtility.php:25
‪TYPO3\CMS\Core\Utility\HttpUtility
Definition: HttpUtility.php:21
‪TYPO3\CMS\Frontend\Utility\CanonicalizationUtility\getParamsToExcludeForCanonicalizedUrl
‪static array getParamsToExcludeForCanonicalizedUrl(int $pageId, array $additionalCanonicalizedUrlParameters=[])
Definition: CanonicalizationUtility.php:41
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45