diff --git a/.gitignore b/.gitignore index d07cc8f..bd2249f 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,4 @@ var /typo3conf /vendor .php_cs.cache +Tests/Unit/.phpunit.cache \ No newline at end of file diff --git a/Classes/Controller/BanController.php b/Classes/Controller/BanController.php index bc28f97..d4557fb 100644 --- a/Classes/Controller/BanController.php +++ b/Classes/Controller/BanController.php @@ -31,7 +31,7 @@ use Aoe\Varnish\System\Varnish; use Psr\Http\Message\ResponseInterface; use TYPO3\CMS\Backend\Template\ModuleTemplateFactory; -use TYPO3\CMS\Core\Messaging\AbstractMessage; +use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; class BanController extends ActionController @@ -49,15 +49,15 @@ public function __construct(ModuleTemplateFactory $moduleTemplateFactory, Varnis public function indexAction(): ResponseInterface { $moduleTemplate = $this->moduleTemplateFactory->create($this->request); - $moduleTemplate->setContent($this->view->render()); - return $this->htmlResponse($moduleTemplate->renderContent()); + + return $moduleTemplate->renderResponse('index'); } public function confirmBanTypo3PagesAction(): ResponseInterface { $moduleTemplate = $this->moduleTemplateFactory->create($this->request); - $moduleTemplate->setContent($this->view->render()); - return $this->htmlResponse($moduleTemplate->renderContent()); + + return $moduleTemplate->renderResponse('confirmBanTypo3Pages'); } public function banTypo3PagesAction(): void @@ -70,23 +70,23 @@ public function banTypo3PagesAction(): void if ($result['success']) { $this->addFlashMessage($result['reason']); } else { - $this->addFlashMessage($result['reason'], '', AbstractMessage::ERROR); + $this->addFlashMessage($result['reason'], '', ContextualFeedbackSeverity::ERROR); } } - $this->redirect('index'); + return $this->redirect('index'); } public function confirmBanTagByNameAction(string $tagName): ResponseInterface { if ($this->isValidTagName($tagName)) { - $this->view->assign('tagName', $tagName); $moduleTemplate = $this->moduleTemplateFactory->create($this->request); - $moduleTemplate->setContent($this->view->render()); - return $this->htmlResponse($moduleTemplate->renderContent()); + $moduleTemplate->assign('tagName', $tagName); + + return $moduleTemplate->renderResponse('confirmBanTagByName'); } - $this->redirect('index'); + return $this->redirect('index'); } public function banTagByNameAction(string $tagName): void @@ -99,7 +99,7 @@ public function banTagByNameAction(string $tagName): void if ($result['success']) { $this->addFlashMessage($result['reason']); } else { - $this->addFlashMessage($result['reason'], '', AbstractMessage::ERROR); + $this->addFlashMessage($result['reason'], '', ContextualFeedbackSeverity::ERROR); } } @@ -111,8 +111,9 @@ public function confirmBanByRegexAction(string $regex): ResponseInterface if (!$this->isCriticalRegex($regex)) { $this->view->assign('regex', $regex); $moduleTemplate = $this->moduleTemplateFactory->create($this->request); - $moduleTemplate->setContent($this->view->render()); - return $this->htmlResponse($moduleTemplate->renderContent()); + $moduleTemplate->assign('regex', $regex); + + return $moduleTemplate->renderResponse('confirmBanByRegex'); } $this->redirect('index'); @@ -128,7 +129,7 @@ public function banByRegexAction(string $regex): void if ($result['success']) { $this->addFlashMessage($result['reason']); } else { - $this->addFlashMessage($result['reason'], '', AbstractMessage::ERROR); + $this->addFlashMessage($result['reason'], '', ContextualFeedbackSeverity::ERROR); } } @@ -138,7 +139,7 @@ public function banByRegexAction(string $regex): void private function isCriticalRegex(string $regex): bool { if (strlen($regex) < 6) { - $this->addFlashMessage('Bitte geben Sie einen spezifischeren RegEx ein!', '', AbstractMessage::ERROR); + $this->addFlashMessage('Bitte geben Sie einen spezifischeren RegEx ein!', '', ContextualFeedbackSeverity::ERROR); return true; } @@ -148,7 +149,7 @@ private function isCriticalRegex(string $regex): bool private function isValidTagName(string $tagName): bool { if (strlen($tagName) < 2) { - $this->addFlashMessage('Bitte geben Sie einen gültigen Tag-Namen ein! ', '', AbstractMessage::ERROR); + $this->addFlashMessage('Bitte geben Sie einen gültigen Tag-Namen ein! ', '', ContextualFeedbackSeverity::ERROR); return false; } diff --git a/Classes/EventListener/ClearCacheMenu.php b/Classes/EventListener/ClearCacheMenu.php new file mode 100644 index 0000000..6121d07 --- /dev/null +++ b/Classes/EventListener/ClearCacheMenu.php @@ -0,0 +1,30 @@ + 'varnish', + 'title' => 'LLL:EXT:varnish/Resources/Private/Language/locallang.xlf:backendAjaxHook.title', + 'description' => 'LLL:EXT:varnish/Resources/Private/Language/locallang.xlf:backendAjaxHook.description', + 'href' => (string) $uriBuilder->buildUriFromRoute('ajax_varnish_ban_all'), + 'iconIdentifier' => 'varnish', + ]; + + $event->addCacheAction($cacheAction); + } +} diff --git a/Classes/EventListener/Crawler.php b/Classes/EventListener/Crawler.php new file mode 100644 index 0000000..bb22497 --- /dev/null +++ b/Classes/EventListener/Crawler.php @@ -0,0 +1,59 @@ +getController(); + + $this->clearVarnishCache($TypoScriptFrontendController); + } + + public function clearVarnishCache(TypoScriptFrontendController $parentObject): void + { + if ($this->isCrawlerExtensionLoaded() && $this->isCrawlerRunning($parentObject)) { + $this->clearPageCacheInVarnish($parentObject->id); + } + } + + protected function isCrawlerExtensionLoaded(): bool + { + return ExtensionManagementUtility::isLoaded('crawler'); + } + + protected function getVarnish(): Varnish + { + $this->varnish ??= GeneralUtility::makeInstance(Varnish::class); + return $this->varnish; + } + + private function clearPageCacheInVarnish(int $pageId): void + { + $pageIdTag = new PageIdTag($pageId); + + $varnish = $this->getVarnish(); + $varnish->banByTag($pageIdTag); + } + + private function isCrawlerRunning(TypoScriptFrontendController $tsfe): bool + { + return isset($tsfe->applicationData['tx_crawler']['running']); + } +} diff --git a/Classes/TYPO3/Hooks/ClearCacheMenuHook.php b/Classes/TYPO3/Hooks/ClearCacheMenuHook.php deleted file mode 100644 index 8defa26..0000000 --- a/Classes/TYPO3/Hooks/ClearCacheMenuHook.php +++ /dev/null @@ -1,53 +0,0 @@ - - * - * All rights reserved - * - * This script is part of the TYPO3 project. The TYPO3 project is - * free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * The GNU General Public License can be found at - * http://www.gnu.org/copyleft/gpl.html. - * - * This script is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * This copyright notice MUST APPEAR in all copies of the script! - ***************************************************************/ - -use TYPO3\CMS\Backend\Routing\UriBuilder; -use TYPO3\CMS\Backend\Toolbar\ClearCacheActionsHookInterface; -use TYPO3\CMS\Core\Utility\GeneralUtility; - -class ClearCacheMenuHook extends AbstractHook implements ClearCacheActionsHookInterface -{ - /** - * @param array $cacheActions - * @param array $optionValues - */ - public function manipulateCacheActions(&$cacheActions, &$optionValues): void - { - $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); - $ajaxUrl = $uriBuilder->buildUriFromRoute('ajax_varnish_ban_all'); - - $cacheActions[] = [ - 'id' => 'varnish', - 'title' => 'LLL:EXT:varnish/Resources/Private/Language/locallang.xlf:backendAjaxHook.title', - // Use empty description because otherwise title will also be used for it - 'description' => 'LLL:EXT:varnish/Resources/Private/Language/locallang.xlf:backendAjaxHook.description', - 'href' => $ajaxUrl, - 'iconIdentifier' => 'varnish', - ]; - } -} diff --git a/Classes/TYPO3/Hooks/CrawlerHook.php b/Classes/TYPO3/Hooks/CrawlerHook.php deleted file mode 100644 index ea026f2..0000000 --- a/Classes/TYPO3/Hooks/CrawlerHook.php +++ /dev/null @@ -1,65 +0,0 @@ - - * - * All rights reserved - * - * This script is part of the TYPO3 project. The TYPO3 project is - * free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * The GNU General Public License can be found at - * http://www.gnu.org/copyleft/gpl.html. - * - * This script is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * This copyright notice MUST APPEAR in all copies of the script! - ***************************************************************/ - -use Aoe\Varnish\Domain\Model\Tag\PageIdTag; -use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; -use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; - -class CrawlerHook extends AbstractHook -{ - /** - * (Hook-function called from TypoScriptFrontend, see ext_localconf.php for configuration). - * - * @param array $parameters Parameters delivered by TypoScriptFrontend - * @param TypoScriptFrontendController $parentObject The calling parent object (TypoScriptFrontend) - */ - public function clearVarnishCache(array $parameters, TypoScriptFrontendController $parentObject): void - { - if ($this->isCrawlerExtensionLoaded() && $this->isCrawlerRunning($parentObject)) { - $this->clearPageCacheInVarnish($parentObject->id); - } - } - - protected function isCrawlerExtensionLoaded(): bool - { - return ExtensionManagementUtility::isLoaded('crawler'); - } - - private function clearPageCacheInVarnish(int $pageId): void - { - $pageIdTag = new PageIdTag($pageId); - - $varnish = $this->getVarnish(); - $varnish->banByTag($pageIdTag); - } - - private function isCrawlerRunning(TypoScriptFrontendController $tsfe): bool - { - return isset($tsfe->applicationData['tx_crawler']['running']); - } -} diff --git a/Configuration/Icons.php b/Configuration/Icons.php new file mode 100644 index 0000000..45249e6 --- /dev/null +++ b/Configuration/Icons.php @@ -0,0 +1,15 @@ + [ + // Icon provider class + 'provider' => SvgIconProvider::class, + // The source SVG for the SvgIconProvider + 'source' => 'EXT:varnish/Resources/Public/Icons/Extension.svg', + ] +]; diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index 2459882..373c94f 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -5,4 +5,16 @@ services: public: false Aoe\Varnish\: - resource: '../Classes/*' \ No newline at end of file + resource: '../Classes/*' + + Aoe\Varnish\EventListener\Crawler: + tags: + - name: event.listener + identifier: 'aoe-varnish/crawler-hook' + event: TYPO3\CMS\Frontend\Event\ShouldUseCachedPageDataIfAvailableEvent + + Aoe\Varnish\EventListener\ClearCacheMenu: + tags: + - name: event.listener + identifier: 'aoe-varnish/toolbar/clear-cache-menu' + event: TYPO3\CMS\Backend\Backend\Event\ModifyClearCacheActionsEvent \ No newline at end of file diff --git a/Configuration/TCA/Overrides/pages.php b/Configuration/TCA/Overrides/pages.php index a1f259b..ec6c4b1 100644 --- a/Configuration/TCA/Overrides/pages.php +++ b/Configuration/TCA/Overrides/pages.php @@ -1,9 +1,10 @@ [ 'exclude' => 0, 'label' => 'LLL:EXT:varnish/Resources/Private/Language/locallang_db.xlf:varnish.field', @@ -14,7 +15,7 @@ ] ]); -\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToPalette( +ExtensionManagementUtility::addFieldsToPalette( 'pages', 'caching', 'varnish_cache' diff --git a/Tests/Unit/System/HeaderTest.php b/Tests/Unit/System/HeaderTest.php index 514fb6b..b8ebfba 100644 --- a/Tests/Unit/System/HeaderTest.php +++ b/Tests/Unit/System/HeaderTest.php @@ -39,6 +39,7 @@ class HeaderTest extends UnitTestCase protected function setUp(): void { + parent::setUp(); $this->header = new Header(); } diff --git a/Tests/Unit/System/HttpTest.php b/Tests/Unit/System/HttpTest.php index 22263bc..35e8060 100644 --- a/Tests/Unit/System/HttpTest.php +++ b/Tests/Unit/System/HttpTest.php @@ -45,6 +45,8 @@ class HttpTest extends UnitTestCase protected function setUp(): void { + parent::setUp(); + $this->client = $this->getMockBuilder(Client::class) ->onlyMethods(['requestAsync']) ->disableOriginalConstructor() diff --git a/Tests/Unit/System/VarnishTest.php b/Tests/Unit/System/VarnishTest.php index 0fb28b5..6656f08 100644 --- a/Tests/Unit/System/VarnishTest.php +++ b/Tests/Unit/System/VarnishTest.php @@ -59,6 +59,8 @@ class VarnishTest extends UnitTestCase protected function setUp(): void { + parent::setUp(); + $this->http = $this->getMockBuilder(Http::class) ->onlyMethods(['request', 'wait']) ->disableOriginalConstructor() diff --git a/Tests/Unit/TYPO3/AdditionalResponseHeadersTest.php b/Tests/Unit/TYPO3/AdditionalResponseHeadersTest.php index 5cf9d6d..d6f1aef 100644 --- a/Tests/Unit/TYPO3/AdditionalResponseHeadersTest.php +++ b/Tests/Unit/TYPO3/AdditionalResponseHeadersTest.php @@ -84,10 +84,7 @@ public function testShouldNotSendVarnishEnabledHeader(): void $subject->process($requestMock, $handlerMock); } - /** - * @return ExtensionConfiguration|MockObject - */ - private function createExtensionConfigurationMock(bool $isDebugEnabled) + private function createExtensionConfigurationMock(bool $isDebugEnabled): MockObject { $extensionConfigurationMock = $this->getMockBuilder(ExtensionConfiguration::class)->disableOriginalConstructor()->getMock(); $extensionConfigurationMock->expects(self::once()) @@ -96,14 +93,11 @@ private function createExtensionConfigurationMock(bool $isDebugEnabled) return $extensionConfigurationMock; } - /** - * @return MockObject - */ private function createHeaderMock( int $sendEnabledHeaderCallingCount, int $sendHeaderForTagCallingCount, int $sendDebugHeaderCallingCount - ) { + ): MockObject { $header = $this->getMockBuilder(Header::class) ->disableOriginalConstructor() ->onlyMethods(['sendEnabledHeader', 'sendHeaderForTag', 'sendDebugHeader']) @@ -117,10 +111,7 @@ private function createHeaderMock( return $header; } - /** - * @return ServerRequestInterface MockObject - */ - private function createRequestMock(bool $isVanishCacheEnabled) + private function createRequestMock(bool $isVanishCacheEnabled): MockObject { $frontendController = $this ->getMockBuilder(TypoScriptFrontendController::class) diff --git a/Tests/Unit/TYPO3/Hooks/CrawlerHookTest.php b/Tests/Unit/TYPO3/Hooks/CrawlerHookTest.php index b7a80e5..e206e76 100644 --- a/Tests/Unit/TYPO3/Hooks/CrawlerHookTest.php +++ b/Tests/Unit/TYPO3/Hooks/CrawlerHookTest.php @@ -27,8 +27,8 @@ ***************************************************************/ use Aoe\Varnish\Domain\Model\Tag\PageIdTag; +use Aoe\Varnish\EventListener\Crawler; use Aoe\Varnish\System\Varnish; -use Aoe\Varnish\TYPO3\Hooks\CrawlerHook; use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -38,7 +38,7 @@ class CrawlerHookTest extends UnitTestCase private Varnish $varnish; - private CrawlerHook $crawlerHook; + private Crawler $crawlerEvent; public function testShouldClearVarnishCache(): void { @@ -48,7 +48,7 @@ public function testShouldClearVarnishCache(): void $this->varnish->expects(self::once())->method('banByTag')->with(new PageIdTag($pageId)); $tsfe = $this->createTsfeMock($pageId, true); - $this->crawlerHook->clearVarnishCache([], $tsfe); + $this->crawlerEvent->clearVarnishCache($tsfe); } public function testShouldNotClearVarnishCacheWhenCrawlerExtensionIsNotLoaded(): void @@ -59,7 +59,7 @@ public function testShouldNotClearVarnishCacheWhenCrawlerExtensionIsNotLoaded(): $this->varnish->expects(self::never())->method('banByTag'); $tsfe = $this->createTsfeMock($pageId, false); - $this->crawlerHook->clearVarnishCache([], $tsfe); + $this->crawlerEvent->clearVarnishCache($tsfe); } public function testShouldNotClearVarnishCacheWhenCrawlerIsNotRunning(): void @@ -70,7 +70,7 @@ public function testShouldNotClearVarnishCacheWhenCrawlerIsNotRunning(): void $this->varnish->expects(self::never())->method('banByTag'); $tsfe = $this->createTsfeMock($pageId, false); - $this->crawlerHook->clearVarnishCache([], $tsfe); + $this->crawlerEvent->clearVarnishCache($tsfe); } private function createTsfeMock(int $pageId, bool $isCrawlerRunning): TypoScriptFrontendController @@ -92,8 +92,8 @@ private function initializeTest(bool $isCrawlerExtensionLoaded): void ->onlyMethods(['banByTag', 'banAll']) ->getMock(); - $this->crawlerHook = $this->createPartialMock(CrawlerHook::class, ['isCrawlerExtensionLoaded', 'getVarnish']); - $this->crawlerHook->expects(self::any())->method('getVarnish')->willReturn($this->varnish); - $this->crawlerHook->expects(self::any())->method('isCrawlerExtensionLoaded')->willReturn($isCrawlerExtensionLoaded); + $this->crawlerEvent = $this->createPartialMock(Crawler::class, ['isCrawlerExtensionLoaded', 'getVarnish']); + $this->crawlerEvent->expects(self::any())->method('getVarnish')->willReturn($this->varnish); + $this->crawlerEvent->expects(self::any())->method('isCrawlerExtensionLoaded')->willReturn($isCrawlerExtensionLoaded); } } diff --git a/Tests/Unit/TYPO3/Hooks/TceMainHookTest.php b/Tests/Unit/TYPO3/Hooks/TceMainHookTest.php index f208336..3b9c6b4 100644 --- a/Tests/Unit/TYPO3/Hooks/TceMainHookTest.php +++ b/Tests/Unit/TYPO3/Hooks/TceMainHookTest.php @@ -62,6 +62,8 @@ class TceMainHookTest extends UnitTestCase */ protected function setUp(): void { + parent::setUp(); + /** https://github.com/TYPO3/TYPO3.CMS/blob/master/typo3/sysext/backend/Tests/Unit/Utility/BackendUtilityTest.php#L1044-L1053 */ $cacheConfigurations = [ 'runtime' => [ diff --git a/Tests/Unit/UnitTests.xml b/Tests/Unit/UnitTests.xml new file mode 100644 index 0000000..9177062 --- /dev/null +++ b/Tests/Unit/UnitTests.xml @@ -0,0 +1,25 @@ + + + + + ../Classes + + + diff --git a/code-quality/phpstan.neon b/code-quality/phpstan.neon index 09d8aa9..f64d040 100644 --- a/code-quality/phpstan.neon +++ b/code-quality/phpstan.neon @@ -9,8 +9,6 @@ parameters: - "../Classes/" inferPrivatePropertyTypeFromConstructor: true - checkMissingIterableValueType: false - checkGenericClassInNonGenericObjectType: false services: - diff --git a/code-quality/rector.php b/code-quality/rector.php index 44162ab..27f0100 100644 --- a/code-quality/rector.php +++ b/code-quality/rector.php @@ -5,10 +5,8 @@ use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector; use Rector\Config\RectorConfig; use Rector\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector; -use Rector\EarlyReturn\Rector\If_\ChangeAndIfToEarlyReturnRector; use Rector\Set\ValueObject\SetList; use Rector\PHPUnit\Set\PHPUnitSetList; -use Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector; use Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector; use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictSetUpRector; @@ -33,8 +31,6 @@ PHPUnitSetList::PHPUNIT_CODE_QUALITY ]) ->withSkip([ - FinalizeClassesWithoutChildrenRector::class, - ChangeAndIfToEarlyReturnRector::class, TypedPropertyFromStrictSetUpRector::class, AddMethodCallBasedStrictParamTypeRector::class, FlipTypeControlToUseExclusiveTypeRector::class, diff --git a/composer.json b/composer.json index ee2458e..7869c57 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "typo3/cms-extbase": "^11.5 || ^12.4" }, "require-dev": { - "typo3/testing-framework": "^7.0.4", + "typo3/testing-framework": "^7.0 || ^8.0", "phpcompatibility/php-compatibility": "^9.3", "phpstan/phpstan": "^1.10", "rector/rector": "^1.0", @@ -56,7 +56,7 @@ ], "test:unit": [ "[ -e .Build/bin/phpunit ] || composer update", - "TYPO3_PATH_ROOT=.Build/Web .Build/bin/phpunit -c .Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTests-v10.xml Tests/Unit/" + "XDEBUG_MODE=coverage TYPO3_PATH_WEB=$PWD/.Build/Web .Build/bin/phpunit -c Tests/Unit/UnitTests.xml Tests/Unit" ], "code-style": [ "[ -e ./.Build/bin/rector ] || composer install", @@ -70,13 +70,10 @@ "./.Build/bin/phpstan analyse -c code-quality/phpstan.neon --memory-limit=1G --generate-baseline --allow-empty-baseline" ], "code-compatibility": [ - "[ -e ./.Build/vendor/symplify/easy-coding-standard/vendor/squizlabs/php_codesniffer/bin/phpcs ] || composer install", + "[ -e ./.Build/vendor/symplify/easy-coding-standard/vendor/squizlabs/php_codesniffer/bin/phpcs ] || composer update", "[ -d ./reports/php_checkstyle ] || mkdir -p reports/php_checkstyle/", "./code-quality/configure-checkstyle.sh", - "./.Build/vendor/symplify/easy-coding-standard/vendor/squizlabs/php_codesniffer/bin/phpcs -d memory_limit=1G --standard=PHPCompatibility --colors --ignore=*/.Build/*,*.min.js -p . --runtime-set testVersion 7.4", "./.Build/vendor/symplify/easy-coding-standard/vendor/squizlabs/php_codesniffer/bin/phpcs -d memory_limit=1G --standard=PHPCompatibility --colors --ignore=*/.Build/*,*.min.js -p . --runtime-set testVersion 8.0", - "./.Build/vendor/symplify/easy-coding-standard/vendor/squizlabs/php_codesniffer/bin/phpcs -d memory_limit=1G --standard=PHPCompatibility --colors --ignore=*/.Build/*,*.min.js -p . --runtime-set testVersion 8.1", - "./.Build/vendor/symplify/easy-coding-standard/vendor/squizlabs/php_codesniffer/bin/phpcs -d memory_limit=1G --standard=PHPCompatibility --colors --ignore=*/.Build/*,*.min.js -p . --runtime-set testVersion 8.2", "./.Build/vendor/symplify/easy-coding-standard/vendor/squizlabs/php_codesniffer/bin/phpcs -d memory_limit=1G --standard=PHPCompatibility --colors --ignore=*/.Build/*,*.min.js -p . --runtime-set testVersion 8.3" ], "code-check-pipeline": [ diff --git a/ext_emconf.php b/ext_emconf.php index 5b69002..7e005bd 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -4,10 +4,10 @@ 'title' => 'TYPO3 Varnish', 'description' => 'Allow varnish connection within TYPO3', 'category' => 'misc', - 'version' => '11.1.1', + 'version' => '12.0.0', 'constraints' => [ 'depends' => [ - 'typo3' => '11.5.0-12.4.99', + 'typo3' => '12.4.0-12.4.99', ], 'conflicts' => [], 'suggests' => [], diff --git a/ext_localconf.php b/ext_localconf.php index 288d8ca..3f97984 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -1,31 +1,8 @@ clearVarnishCache'; +defined('TYPO3') or die(); /** - * Hook to clear varnish-cache - hook is called whenever the cache of an page should be deleted + * Hook to clear varnish-cache - hook is called whenever the cache of a page should be deleted * Is used in TYPO3-Context: FE and BE */ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearCachePostProc'][] = Aoe\Varnish\TYPO3\Hooks\TceMainHook::class .'->clearCachePostProc'; - -if (TYPO3_MODE === 'BE') { - /** @var IconRegistry $iconRegistry */ - $iconRegistry = GeneralUtility::makeInstance(IconRegistry::class); - $iconRegistry->registerIcon('varnish', SvgIconProvider::class, ['source' => 'EXT:varnish/Resources/Public/Icons/Extension.svg']); - - /** - * Hook to add 'clear-varnish-cache'-button in TYPO3-BE - */ - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['additionalBackendItems']['cacheActions'][] = Aoe\Varnish\TYPO3\Hooks\ClearCacheMenuHook::class; -} diff --git a/ext_tables.php b/ext_tables.php index aea41c6..230686f 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -1,20 +1,21 @@ 'index,banTypo3Pages,confirmBanTypo3Pages,banTagByName,confirmBanTagByName,banByRegex,confirmBanByRegex' - ], - [ - 'access' => 'user,group', - 'icon' => 'EXT:varnish/Resources/Public/Icons/Extension.svg', - 'labels' => 'LLL:EXT:varnish/Resources/Private/Language/locallang_mod.xlf' - ] - ); -} +defined('TYPO3') or die(); + +ExtensionUtility::registerModule( + 'varnish', + 'web', + 'varnish', + 'bottom', + [ + BanController::class => 'index,banTypo3Pages,confirmBanTypo3Pages,banTagByName,confirmBanTagByName,banByRegex,confirmBanByRegex' + ], + [ + 'access' => 'user,group', + 'icon' => 'EXT:varnish/Resources/Public/Icons/Extension.svg', + 'labels' => 'LLL:EXT:varnish/Resources/Private/Language/locallang_mod.xlf' + ] +); \ No newline at end of file