-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BETA][FEATURE] Add TYPO3 v13 compatibility (#778)
* [FEATURE] Add TYPO3 v13 compatibility - adjust tests for T3v13 * [TASK] Improve tests for v13 LTS & PHPUnit v11 * [BUGFIX] Generate proper frontend url for hreflangs * [TASK] Introduce HeadlessVersion TYPO3's Core inspired simple utility to provide small helper to tackle code adjusting for different versions of ext:headless * [TASK] Set version 4.5.0 * [TASK] Adjusting README * [BUGFIX] Call parent properly in CLI context * [BUGFIX] Fix potential warnings * [BUGFIX] Do not try to import on v12 not existing class
- Loading branch information
1 parent
e87413b
commit 3a55bfc
Showing
72 changed files
with
706 additions
and
1,472 deletions.
There are no files selected for viewing
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
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
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
34 changes: 34 additions & 0 deletions
34
Classes/Event/Listener/HeadlessHreflangGeneratorListener.php
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the "headless" Extension for TYPO3 CMS. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.md file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace FriendsOfTYPO3\Headless\Event\Listener; | ||
|
||
use FriendsOfTYPO3\Headless\Utility\UrlUtility; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3\CMS\Frontend\Event\ModifyHrefLangTagsEvent; | ||
|
||
/** | ||
* @codeCoverageIgnore | ||
*/ | ||
class HeadlessHreflangGeneratorListener | ||
{ | ||
public function __invoke(ModifyHrefLangTagsEvent $event): void | ||
{ | ||
$hrefLangs = []; | ||
$urlUtility = GeneralUtility::makeInstance(UrlUtility::class)->withRequest($event->getRequest()); | ||
|
||
foreach ($event->getHrefLangs() as $lang => $hrefLang) { | ||
$hrefLangs[$lang] = $urlUtility->getFrontendUrlWithSite($hrefLang, $event->getRequest()->getAttribute('site')); | ||
} | ||
|
||
$event->setHrefLangs($hrefLangs); | ||
} | ||
} |
Oops, something went wrong.