-
-
Save Nimmermaer/2feab3af3cc0fa8f5f79be64ebd00d20 to your computer and use it in GitHub Desktop.
Realurl encode / decode for LTS 9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['extensionkey']['UrlReplacements'] = [ | |
'newsroom/presse/details/tx_news/' => 'newsroom/presse/', | |
'newsroom/aktuelles/details/tx_news/' => 'newsroom/aktuelles/', | |
'newsroom/veranstaltungskalender/details/tx_news/' => 'newsroom/veranstaltungskalender/' | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Decods the uri | |
*/ | |
class DecodeUri implements MiddlewareInterface | |
{ | |
/** | |
* Starting time tracking (by setting up a singleton object) | |
* | |
* @param ServerRequestInterface $request | |
* @param RequestHandlerInterface $handler | |
* @return ResponseInterface | |
*/ | |
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface | |
{ | |
foreach($GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['extensionkey']['UrlReplacements'] as $replacement => $currentUri) { | |
if(stristr($request->getUri()->getPath(), $currentUri) !== false) { | |
$uriParts = explode($currentUri, $request->getUri()->getPath()); | |
if (substr_count($uriParts[1], '/') < 1) { | |
$uri = $request->getUri()->withPath(str_replace($currentUri, $replacement, $request->getUri()->getPath())); | |
$request = $request->withUri($uri); | |
} | |
} | |
} | |
return $handler->handle($request); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['typoLink_PostProc'][] = 'Vendor\ExtensionName\Utility\NewsTypolinkManipulator->main'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class NewsTypolinkManipulator | |
{ | |
public function main(&$param, $pObj) | |
{ | |
$param['finalTag'] = str_replace(array_keys($GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['extensionkey']['UrlReplacements']), array_values($GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['extensionkey']['UrlReplacements']), $param['finalTag']); | |
$param['finalTagParts']['url'] = str_replace(array_keys($GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['extensionkey']['UrlReplacements']), array_values($GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['extensionkey']['UrlReplacements']), $param['finalTagParts']['url']); | |
$param['tagAttributes']['href'] = str_replace(array_keys($GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['extensionkey']['UrlReplacements']), array_values($GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['extensionkey']['UrlReplacements']), $param['tagAttributes']['href']); | |
$pObj->lastTypoLinkUrl = str_replace(array_keys($GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['extensionkey']['UrlReplacements']), array_values($GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['extensionkey']['UrlReplacements']), $pObj->lastTypoLinkUrl); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
return [ | |
'frontend' => [ | |
'vendor/extensionkey/decode-uri' => [ | |
'target' => \Vendor\ExtensionKey\Middleware\DecodeUri::class, | |
'description' => '', | |
'before' => [ | |
'typo3/cms-frontend/timetracker', | |
], | |
] | |
] | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment