Skip to content

Commit f565f07

Browse files
soyukaKDederichs
andauthored
chore(symfony): ValueResolverInterface deprecation (api-platform#5334)
Co-authored-by: Kai Dederichs <[email protected]>
1 parent 7a85751 commit f565f07

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the API Platform project.
5+
*
6+
* (c) Kévin Dunglas <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace ApiPlatform\Symfony\Bundle\ArgumentResolver;
15+
16+
use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface;
17+
use Symfony\Component\HttpKernel\Controller\ValueResolverInterface;
18+
19+
if (interface_exists(ValueResolverInterface::class)) {
20+
/** @internal */
21+
interface CompatibleValueResolverInterface extends ValueResolverInterface
22+
{
23+
}
24+
} else {
25+
/** @internal */
26+
interface CompatibleValueResolverInterface extends ArgumentValueResolverInterface
27+
{
28+
}
29+
}

src/Symfony/Bundle/ArgumentResolver/PayloadArgumentResolver.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
use Symfony\Component\HttpKernel\Controller\ValueResolverInterface;
2222
use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
2323

24-
final class PayloadArgumentResolver implements ValueResolverInterface
24+
final class PayloadArgumentResolver implements CompatibleValueResolverInterface
2525
{
2626
use OperationRequestInitiatorTrait;
2727

@@ -59,8 +59,10 @@ public function supports(Request $request, ArgumentMetadata $argument): bool
5959

6060
public function resolve(Request $request, ArgumentMetadata $argument): \Generator
6161
{
62-
if (!$this->supports($request, $argument)) {
63-
yield [];
62+
if (interface_exists(ValueResolverInterface::class)) {
63+
if (!$this->supports($request, $argument)) {
64+
yield [];
65+
}
6466
}
6567

6668
yield $request->attributes->get('data');

0 commit comments

Comments
 (0)