-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: CD-319266 First tagged TYPO3 v12 version
- Loading branch information
1 parent
adc120d
commit c2cf70e
Showing
22 changed files
with
209 additions
and
216 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,4 @@ var | |
/typo3conf | ||
/vendor | ||
.php_cs.cache | ||
Tests/Unit/.phpunit.cache |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Aoe\Varnish\EventListener; | ||
|
||
use TYPO3\CMS\Backend\Backend\Event\ModifyClearCacheActionsEvent; | ||
use TYPO3\CMS\Backend\Routing\UriBuilder; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
final class ClearCacheMenu | ||
{ | ||
/** | ||
* Hook to add 'clear-varnish-cache'-button in TYPO3-BE | ||
*/ | ||
public function __invoke(ModifyClearCacheActionsEvent $event): void | ||
{ | ||
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); | ||
|
||
$cacheAction = [ | ||
'id' => '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); | ||
} | ||
} |
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,59 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Aoe\Varnish\EventListener; | ||
|
||
use Aoe\Varnish\Domain\Model\Tag\PageIdTag; | ||
use Aoe\Varnish\System\Varnish; | ||
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; | ||
use TYPO3\CMS\Frontend\Event\ShouldUseCachedPageDataIfAvailableEvent; | ||
|
||
class Crawler | ||
{ | ||
protected Varnish $varnish; | ||
|
||
/** | ||
* Hook to clear varnish-cache - hook is called when crawler-extension crawl the page | ||
* Is used in TYPO3-Context: FE (but we should always see those hooks also in the BE-configuration-module for a better overview of configured hooks) | ||
*/ | ||
public function __invoke(ShouldUseCachedPageDataIfAvailableEvent $event): void | ||
{ | ||
$TypoScriptFrontendController = $event->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']); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider; | ||
|
||
return [ | ||
// Icon identifier | ||
'varnish' => [ | ||
// Icon provider class | ||
'provider' => SvgIconProvider::class, | ||
// The source SVG for the SvgIconProvider | ||
'source' => 'EXT:varnish/Resources/Public/Icons/Extension.svg', | ||
] | ||
]; |
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
Oops, something went wrong.