Skip to content

Commit

Permalink
[TASK] Add compatibility for TYPO3 v13
Browse files Browse the repository at this point in the history
  • Loading branch information
featdd committed Nov 17, 2024
1 parent 29da54f commit 274cb2f
Show file tree
Hide file tree
Showing 23 changed files with 1,736 additions and 1,718 deletions.
19 changes: 7 additions & 12 deletions Classes/Domain/Repository/AbstractTermRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,14 @@ public function findByNameLength(): array
{
$terms = $this->findAll()->toArray();

/**
* Sorting Callback
*
* @param Term $termA
* @param Term $termB
* @return int
*/
$sortingCallback = function (TermInterface $termA, TermInterface $termB) {
return mb_strlen($termB->getName()) - mb_strlen($termA->getName());
};

// Sort terms
usort($terms, $sortingCallback);
usort(
$terms,
fn(
TermInterface $termA,
TermInterface $termB
) => mb_strlen($termB->getName()) - mb_strlen($termA->getName())
);

return $terms;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,62 @@
*
***/

use Featdd\DpnGlossary\Service\ParserService;
use RuntimeException;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Extbase\Configuration\Exception\InvalidConfigurationTypeException;
use TYPO3\CMS\Frontend\Event\AfterCacheableContentIsGeneratedEvent;

/**
* @package Featdd\DpnGlossary\EventListener
*/
class AfterCacheableContentIsGeneratedEventListener
{
use ParseHtmlEventTrait;
/**
* @var \Featdd\DpnGlossary\Service\ParserService
*/
protected ParserService $parserService;

public function __construct()
{
$this->parserService = GeneralUtility::makeInstance(ParserService::class);
}

/**
* @param \TYPO3\CMS\Frontend\Event\AfterCacheableContentIsGeneratedEvent $afterCacheableContentIsGeneratedEvent
* @throws \Featdd\DpnGlossary\Service\Exception
*/
public function __invoke(AfterCacheableContentIsGeneratedEvent $afterCacheableContentIsGeneratedEvent): void
{
$this->parseHtml($afterCacheableContentIsGeneratedEvent->getController());
$typoScriptFrontendController = $afterCacheableContentIsGeneratedEvent->getController();
$request = $afterCacheableContentIsGeneratedEvent->getRequest();

/** @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManager $configurationManager */
$configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class);

try {
$settings = $configurationManager->getConfiguration(
ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS,
'dpnglossary'
);

$isDisableParser = (bool)($settings['disableParser'] ?? false);
} catch (InvalidConfigurationTypeException|RuntimeException) {
$isDisableParser = true;
}

if ($typoScriptFrontendController->page['tx_dpnglossary_disable_parser']) {
$isDisableParser = true;
}

if (!$isDisableParser) {
$parsedHTML = $this->parserService->pageParser($request, $typoScriptFrontendController->content);

if (is_string($parsedHTML)) {
$typoScriptFrontendController->content = $parsedHTML;
}
}
}
}
13 changes: 7 additions & 6 deletions Classes/EventListener/ModifyUrlForCanonicalTagEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

use Featdd\DpnGlossary\Domain\Repository\TermRepository;
use Featdd\DpnGlossary\Pagination\CharacterPaginator;
use Featdd\DpnGlossary\Utility\LinkUtility;
use TYPO3\CMS\Core\Site\Entity\Site;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Seo\Event\ModifyUrlForCanonicalTagEvent;

Expand All @@ -25,8 +25,6 @@
*/
class ModifyUrlForCanonicalTagEventListener
{
use ParseHtmlEventTrait;

/**
* @var \Featdd\DpnGlossary\Domain\Repository\TermRepository
*/
Expand Down Expand Up @@ -61,9 +59,13 @@ public function __invoke(ModifyUrlForCanonicalTagEvent $modifyUrlForCanonicalTag
$queryParameters = $request->getQueryParams();
/** @var \TYPO3\CMS\Core\Routing\PageArguments $pageArguments */
$pageArguments = $request->getAttribute('routing');
/** @var \TYPO3\CMS\Core\Site\Entity\Site $site */
$site = $request->getAttribute('site');

if (
$site instanceof Site &&
!isset($queryParameters['tx_dpnglossary_glossary']['currentCharacter']) &&
!isset($queryParameters['tx_dpnglossary_glossary']['term']) &&
$listMode === 'pagination' &&
$pageArguments->getPageId() === $detailPage
) {
Expand All @@ -77,16 +79,15 @@ public function __invoke(ModifyUrlForCanonicalTagEvent $modifyUrlForCanonicalTag

if (!empty($currentCharacter)) {
$modifyUrlForCanonicalTagEvent->setUrl(
LinkUtility::renderTypoLink(
't3://page?uid=' . $detailPage,
(string)$site->getRouter()->generateUri(
$detailPage,
[
'tx_dpnglossary_glossary' => [
'action' => 'list',
'controller' => 'Term',
'currentCharacter' => $currentCharacter,
],
],
true
)
);
}
Expand Down
71 changes: 0 additions & 71 deletions Classes/EventListener/ParseHtmlEventTrait.php

This file was deleted.

48 changes: 0 additions & 48 deletions Classes/Hook/ContentPostProcHook.php

This file was deleted.

Loading

0 comments on commit 274cb2f

Please sign in to comment.