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