Skip to content

Commit eeeb6bd

Browse files
author
Francois Suter
committed
[TASK] Migrate toolbar item to event listener, migrate icon registration code, drop compatibility with TYPO3 9 and 10
1 parent a5c23ed commit eeeb6bd

File tree

7 files changed

+47
-52
lines changed

7 files changed

+47
-52
lines changed

Classes/Toolbar/ToolbarItem.php renamed to Classes/EventListener/ClearCacheListener.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?php
2+
23
declare(strict_types=1);
34

4-
namespace Cobweb\FlushLanguageCache\Toolbar;
5+
namespace Cobweb\FlushLanguageCache\EventListener;
56

67
/**
78
* This file is part of the TYPO3 CMS project.
@@ -16,27 +17,26 @@
1617
* The TYPO3 project - inspiring people to share!
1718
*/
1819

20+
use TYPO3\CMS\Backend\Backend\Event\ModifyClearCacheActionsEvent;
1921
use TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException;
2022
use TYPO3\CMS\Backend\Routing\UriBuilder;
21-
use TYPO3\CMS\Backend\Toolbar\ClearCacheActionsHookInterface;
2223
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
2324
use TYPO3\CMS\Core\Utility\GeneralUtility;
2425

2526
/**
2627
* Prepares additional flush cache entry.
2728
*/
28-
class ToolbarItem implements ClearCacheActionsHookInterface
29+
class ClearCacheListener
2930
{
30-
static public $itemKey = 'flushLanguageCache';
31+
static public string $itemKey = 'flushLanguageCache';
3132

3233
/**
3334
* Adds the flush language cache menu item.
3435
*
35-
* @param array $cacheActions Array of CacheMenuItems
36-
* @param array $optionValues Array of AccessConfigurations-identifiers (typically used by userTS with options.clearCache.identifier)
36+
* @param ModifyClearCacheActionsEvent $event
3737
* @return void
3838
*/
39-
public function manipulateCacheActions(&$cacheActions, &$optionValues)
39+
public function __invoke(ModifyClearCacheActionsEvent $event): void
4040
{
4141
// First check if user has right to access the flush language cache item
4242
$tsConfig = $this->getBackendUser()->getTSConfig();
@@ -46,14 +46,16 @@ public function manipulateCacheActions(&$cacheActions, &$optionValues)
4646
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
4747
try {
4848
$uri = $uriBuilder->buildUriFromRoute('flushLanguageCache');
49-
$cacheActions[] = [
49+
$event->addCacheAction(
50+
[
5051
'id' => self::$itemKey,
5152
'title' => 'LLL:EXT:flush_language_cache/Resources/Private/Language/locallang.xlf:flushLanguageCache',
5253
'description' => 'LLL:EXT:flush_language_cache/Resources/Private/Language/locallang.xlf:flushLanguageCache.description',
5354
'href' => $uri,
5455
'iconIdentifier' => 'tx_flushlanguagecache_flush'
55-
];
56-
$optionValues[] = self::$itemKey;
56+
]
57+
);
58+
$event->addCacheActionIdentifier(self::$itemKey);
5759
} catch (RouteNotFoundException $e) {
5860
// Do nothing, i.e. do not add the menu item if the AJAX route cannot be found
5961
}
@@ -69,4 +71,4 @@ protected function getBackendUser(): BackendUserAuthentication
6971
{
7072
return $GLOBALS['BE_USER'];
7173
}
72-
}
74+
}

Configuration/Icons.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
return [
3+
'tx_flushlanguagecache_flush' => [
4+
'provider' => TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class,
5+
'source' => 'EXT:flush_language_cache/Resources/Public/Icons/FlushCache.svg'
6+
],
7+
];

Configuration/Services.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,8 @@ services:
1414
command: 'languagecache:flush'
1515
description: 'Clears the language cache (l10n).'
1616
schedulable: true
17+
18+
Cobweb\FlushLanguageCache\EventListener\ClearCacheListener:
19+
tags:
20+
- name: event.listener
21+
identifier: 'flush-language-cache/flush'

Resources/Public/Icons/FlushCache.svg

Lines changed: 18 additions & 18 deletions
Loading

composer.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"name": "cobweb/flush_language_cache",
33
"type": "typo3-cms-extension",
44
"description": "Adds an item to the flush cache menu to clear just the language (l10n) cache. Also provides a command-line tool for that.",
5-
"version": "3.0.2",
65
"license": [
76
"GPL-2.0+"
87
],
@@ -18,8 +17,8 @@
1817
}
1918
},
2019
"require": {
21-
"php": ">=7.2.0",
22-
"typo3/cms-core": ">=9.5.0,<12.0"
20+
"php": ">=7.4.0",
21+
"typo3/cms-core": "^11.5 || ^12.0"
2322
},
2423
"replace": {
2524
"typo3-ter/flush_language_cache": "self.version"

ext_emconf.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
'version' => '3.0.2',
1919
'constraints' => [
2020
'depends' => [
21-
'typo3' => '9.5.0-11.5.99',
22-
'php' => '7.2.0-8.0.99'
21+
'typo3' => '11.5.0-12.9.99',
22+
'php' => '7.4.0-8.1.99'
2323
],
2424
'conflicts' => [],
2525
'suggests' => [],

ext_tables.php

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)