Skip to content

Commit 838e76f

Browse files
ZowacPierreRebeilleausoyuka
committed
chore: split api-platform/http-cache (api-platform#5531)
--------- Co-authored-by: PierreRebeilleau <[email protected]> Co-authored-by: Antoine Bluchet <[email protected]>
1 parent 90ce15e commit 838e76f

18 files changed

+362
-13
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ jobs:
193193
- OpenApi
194194
- Metadata
195195
- Elasticsearch
196+
- HttpCache
196197
- RamseyUuid
197198
fail-fast: false
198199
steps:

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,10 @@
120120
"autoload": {
121121
"psr-4": {
122122
"ApiPlatform\\": "src/"
123-
}
123+
},
124+
"files": [
125+
"src/deprecation.php"
126+
]
124127
},
125128
"autoload-dev": {
126129
"psr-4": {

src/HttpCache/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/composer.lock
2+
/vendor
3+
/.phpunit.result.cache

src/HttpCache/EventListener/AddHeadersListener.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
* Configures cache HTTP headers for the current response.
2323
*
2424
* @author Kévin Dunglas <[email protected]>
25+
*
26+
* @deprecated use \Symfony\EventListener\AddHeadersListener.php instead
2527
*/
2628
final class AddHeadersListener
2729
{

src/HttpCache/EventListener/AddTagsListener.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313

1414
namespace ApiPlatform\HttpCache\EventListener;
1515

16-
use ApiPlatform\Api\IriConverterInterface;
17-
use ApiPlatform\Api\UrlGeneratorInterface;
1816
use ApiPlatform\HttpCache\PurgerInterface;
1917
use ApiPlatform\Metadata\CollectionOperationInterface;
18+
use ApiPlatform\Metadata\IriConverterInterface;
2019
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
20+
use ApiPlatform\Metadata\UrlGeneratorInterface;
2121
use ApiPlatform\State\UriVariablesResolverTrait;
2222
use ApiPlatform\Util\OperationRequestInitiatorTrait;
2323
use ApiPlatform\Util\RequestAttributesExtractor;
@@ -34,6 +34,8 @@
3434
* @see https://docs.varnish-software.com/varnish-cache-plus/vmods/ykey/
3535
*
3636
* @author Kévin Dunglas <[email protected]>
37+
*
38+
* @deprecated use \Symfony\EventListener\AddTagsListener.php instead
3739
*/
3840
final class AddTagsListener
3941
{

src/HttpCache/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT license
2+
3+
Copyright (c) 2015-present Kévin Dunglas
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is furnished
10+
to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

src/HttpCache/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# API Platform - HTTP Cache
2+
3+
HTTP Cache support.
4+
5+
## Resources
6+
7+

src/HttpCache/SurrogateKeysPurger.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
namespace ApiPlatform\HttpCache;
1515

16-
use ApiPlatform\Exception\RuntimeException;
16+
use ApiPlatform\Metadata\Exception\RuntimeException;
1717
use Symfony\Component\HttpFoundation\Request;
1818
use Symfony\Contracts\HttpClient\HttpClientInterface;
1919

tests/HttpCache/SouinPurgerTest.php renamed to src/HttpCache/Tests/SouinPurgerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
declare(strict_types=1);
1313

14-
namespace ApiPlatform\Tests\HttpCache;
14+
namespace ApiPlatform\HttpCache\Tests;
1515

1616
use ApiPlatform\HttpCache\SouinPurger;
1717
use GuzzleHttp\ClientInterface;

tests/HttpCache/VarnishPurgerTest.php renamed to src/HttpCache/Tests/VarnishPurgerTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
declare(strict_types=1);
1313

14-
namespace ApiPlatform\Tests\HttpCache;
14+
namespace ApiPlatform\HttpCache\Tests;
1515

1616
use ApiPlatform\HttpCache\VarnishPurger;
1717
use GuzzleHttp\ClientInterface;
@@ -187,4 +187,12 @@ public function testConstructor(): void
187187

188188
$purger->purge(['/foo']);
189189
}
190+
191+
public function testGetResponseHeader(): void
192+
{
193+
$clientProphecy = $this->prophesize(HttpClientInterface::class);
194+
195+
$purger = new VarnishPurger([$clientProphecy->reveal()]);
196+
self::assertSame(['Cache-Tags' => '/foo'], $purger->getResponseHeaders(['/foo']));
197+
}
190198
}

0 commit comments

Comments
 (0)