-
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.
- Loading branch information
Showing
14 changed files
with
108 additions
and
64 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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace HDNET\CdnFastly\Controller; | ||
|
||
use Psr\Http\Message\ResponseFactoryInterface; | ||
use Psr\Http\Message\ResponseInterface; | ||
use TYPO3\CMS\Core\Cache\CacheManager; | ||
|
||
final class ClearCacheController | ||
{ | ||
public function __construct( | ||
public readonly string $cacheGroupIdentifier, | ||
private readonly ResponseFactoryInterface $responseFactory, | ||
private readonly CacheManager $cacheManager, | ||
) {} | ||
|
||
public function __invoke(): ResponseInterface | ||
{ | ||
$this->cacheManager->flushCachesInGroup($this->cacheGroupIdentifier); | ||
|
||
$response = $this->responseFactory | ||
->createResponse() | ||
->withHeader('Content-Type', 'application/json; charset=utf-8'); | ||
$response->getBody()->write(\json_encode('ok')); | ||
|
||
return $response; | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider; | ||
|
||
return [ | ||
'extension-cdn_fastly-clearcache' => [ | ||
'provider' => BitmapIconProvider::class, | ||
'source' => 'EXT:cdn_fastly/Resources/Public/Icons/Cache/FastlyClearCache.png', | ||
], | ||
]; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace HDNET\CdnFastly\Tests\Unit\Controller; | ||
|
||
use HDNET\CdnFastly\Controller\ClearCacheController; | ||
use HDNET\CdnFastly\Tests\Unit\AbstractTestCase; | ||
use Psr\Http\Message\ResponseFactoryInterface; | ||
use TYPO3\CMS\Core\Cache\CacheManager; | ||
|
||
class ClearCacheControllerTest extends AbstractTestCase | ||
{ | ||
/** @test */ | ||
public function canBeInstantiated() | ||
{ | ||
$responseFactory = $this->getMockBuilder(ResponseFactoryInterface::class)->getMock(); | ||
$cacheManager = $this->getMockBuilder(CacheManager::class)->getMock(); | ||
$object = new ClearCacheController('dummy', $responseFactory, $cacheManager); | ||
self::assertInstanceOf(ClearCacheController::class, $object); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,19 @@ | ||
<?php | ||
|
||
use HDNET\CdnFastly\Cache\FastlyBackend; | ||
use HDNET\CdnFastly\Events\FastlyClearCache; | ||
use TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider; | ||
use TYPO3\CMS\Core\Imaging\IconRegistry; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3\CMS\Extbase\Object\Container\Container; | ||
|
||
defined('TYPO3') || die(); | ||
|
||
$boot = static function ( | ||
Container $container | ||
): void { | ||
$boot = static function (): void { | ||
if (empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['CdnFastly'] ?? null)) { | ||
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['CdnFastly'] = [ | ||
'backend' => FastlyBackend::class, | ||
'groups' => [ | ||
'fastly' | ||
'fastly', | ||
], | ||
]; | ||
} | ||
|
||
if (TYPO3_MODE === 'BE') { | ||
$iconRegistry = GeneralUtility::makeInstance(IconRegistry::class); | ||
$iconRegistry->registerIcon( | ||
'extension-cdn_fastly-clearcache', | ||
BitmapIconProvider::class, | ||
['source' => 'EXT:cdn_fastly/Resources/Public/Icons/Cache/FastlyClearCache.png'] | ||
); | ||
|
||
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['additionalBackendItems']['cacheActions'][] = FastlyClearCache::class; | ||
} | ||
}; | ||
|
||
$boot( | ||
GeneralUtility::makeInstance(Container::class) | ||
); | ||
$boot(); | ||
unset($boot); |
This file was deleted.
Oops, something went wrong.