-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #418 from RayTM/master
[BUGFIX] Added missing middleware implementing frontend.cache.instruction for TYPO3 v13
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 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,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SFC\Staticfilecache\Middleware; | ||
|
||
use Psr\Http\Message\ResponseInterface; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use Psr\Http\Server\MiddlewareInterface; | ||
use Psr\Http\Server\RequestHandlerInterface; | ||
use TYPO3\CMS\Frontend\Cache\CacheInstruction; | ||
|
||
class FrontendCacheMiddleware implements MiddlewareInterface | ||
{ | ||
public function process( | ||
ServerRequestInterface $request, | ||
RequestHandlerInterface $handler, | ||
): ResponseInterface | ||
{ | ||
if (class_exists(CacheInstruction::class)) { | ||
// Get the attribute, if not available, use a new CacheInstruction object | ||
$cacheInstruction = $request->getAttribute( | ||
Check failure on line 22 in Classes/Middleware/FrontendCacheMiddleware.php GitHub Actions / build (8.1, 12)
Check failure on line 22 in Classes/Middleware/FrontendCacheMiddleware.php GitHub Actions / build (8.2, 12)
|
||
'frontend.cache.instruction', | ||
new CacheInstruction(), | ||
); | ||
|
||
// Disable the cache and give a reason | ||
$cacheInstruction->disableCache('EXT:staticfilecache: Cache is disabled'); | ||
|
||
// Write back the cache instruction to the attribute | ||
$request = $request->withAttribute('frontend.cache.instruction', $cacheInstruction); | ||
} | ||
return $handler->handle($request); | ||
} | ||
} |
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