-
Notifications
You must be signed in to change notification settings - Fork 60
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
5 changed files
with
146 additions
and
25 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,22 @@ | ||
<?php | ||
|
||
use FOS\HttpCache\SymfonyCache\CacheInvalidation; | ||
use FOS\HttpCache\SymfonyCache\Compatibility\CacheInvalidationS6; | ||
use FOS\HttpCache\SymfonyCache\Compatibility\CacheInvalidationLegacy; | ||
|
||
/* | ||
* Hint phpstan on the class aliases. | ||
* Symfony 6 introduced a BC break in the signature of the protected method HttpKernelInterface::fetch. | ||
* Load the correct interface to match the signature. | ||
*/ | ||
if (version_compare(PHP_VERSION, '8.1.0', '>=')) { | ||
class_alias( | ||
CacheInvalidationS6::class, | ||
CacheInvalidation::class | ||
); | ||
} else { | ||
class_alias( | ||
CacheInvalidationLegacy::class, | ||
CacheInvalidation::class | ||
); | ||
} |
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
47 changes: 47 additions & 0 deletions
47
src/SymfonyCache/Compatibility/CacheInvalidationLegacy.php
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,47 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the FOSHttpCache package. | ||
* | ||
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace FOS\HttpCache\SymfonyCache\Compatibility; | ||
|
||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\HttpKernel\HttpCache\StoreInterface; | ||
use Symfony\Component\HttpKernel\HttpKernelInterface; | ||
|
||
/** | ||
* Interface for a HttpCache that supports active cache invalidation. | ||
* | ||
* Method signature of `fetch` and `getStore` compatible with Symfony 5 and older. | ||
*/ | ||
interface CacheInvalidationLegacy extends HttpKernelInterface | ||
{ | ||
/** | ||
* Forwards the Request to the backend and determines whether the response should be stored. | ||
* | ||
* This methods is triggered when the cache missed or a reload is required. | ||
* | ||
* This method is present on HttpCache but must be public to allow event listeners to do | ||
* refresh operations. | ||
* | ||
* @param Request $request A Request instance | ||
* @param bool $catch Whether to process exceptions | ||
* | ||
* @return Response A Response instance | ||
*/ | ||
public function fetch(Request $request, $catch = false); | ||
|
||
/** | ||
* Gets the store for cached responses. | ||
* | ||
* @return StoreInterface $store The store used by the HttpCache | ||
*/ | ||
public function getStore(); | ||
} |
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,47 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the FOSHttpCache package. | ||
* | ||
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace FOS\HttpCache\SymfonyCache\Compatibility; | ||
|
||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\HttpKernel\HttpCache\StoreInterface; | ||
use Symfony\Component\HttpKernel\HttpKernelInterface; | ||
|
||
/** | ||
* Interface for a HttpCache that supports active cache invalidation. | ||
* | ||
* Method signature of `fetch` and `getStore` compatible with Symfony 6 or newer. | ||
*/ | ||
interface CacheInvalidationS6 extends HttpKernelInterface | ||
{ | ||
/** | ||
* Forwards the Request to the backend and determines whether the response should be stored. | ||
* | ||
* This methods is triggered when the cache missed or a reload is required. | ||
* | ||
* This method is present on HttpCache but must be public to allow event listeners to do | ||
* refresh operations. | ||
* | ||
* @param Request $request A Request instance | ||
* @param bool $catch Whether to process exceptions | ||
* | ||
* @return Response A Response instance | ||
*/ | ||
public function fetch(Request $request, bool $catch = false): Response; | ||
|
||
/** | ||
* Gets the store for cached responses. | ||
* | ||
* @return StoreInterface $store The store used by the HttpCache | ||
*/ | ||
public function getStore(): StoreInterface; | ||
} |