DmitryDulepov\Realurl\Encoder\UrlEncoder::postProcessEncodedUrl PHP Method

postProcessEncodedUrl() public method

Post-processes the URL. If necessary prepends another domain to the URL.
public postProcessEncodedUrl ( array &$parameters, TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $pObj ) : void
$parameters array
$pObj TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
return void
    public function postProcessEncodedUrl(array &$parameters, ContentObjectRenderer $pObj)
    {
        if (isset($parameters['finalTagParts']['url'])) {
            // We must check for absolute URLs here because typolink can force
            // absolute URLs for pages with restricted access. It prepends
            // current host always. See http://bugs.typo3.org/view.php?id=18200
            $testUrl = $parameters['finalTagParts']['url'];
            if (preg_match('/^https?:\\/\\/[^\\/]+\\//', $testUrl)) {
                $testUrl = preg_replace('/https?:\\/\\/[^\\/]+\\/(.*)$/', $this->tsfe->absRefPrefix . '\\1', $testUrl);
            }
            list($testUrl, $section) = GeneralUtility::revExplode('#', $testUrl, 2);
            if (isset(self::$urlPrependRegister[$testUrl])) {
                $urlKey = $url = $testUrl;
                $url = self::$urlPrependRegister[$urlKey] . ($url[0] != '/' ? '/' : '') . $url;
                if ($section) {
                    $url .= '#' . $section;
                }
                unset(self::$urlPrependRegister[$testUrl]);
                // Adjust the URL
                $parameters['finalTag'] = str_replace('"' . htmlspecialchars($parameters['finalTagParts']['url']) . '"', '"' . htmlspecialchars($url) . '"', $parameters['finalTag']);
                $parameters['finalTagParts']['url'] = $url;
                $pObj->lastTypoLinkUrl = $url;
            }
        }
    }