8000 feature #48992 [HttpKernel] Introduce pinnable value resolvers with `… · symfony/doctrine-bridge@669b167 · GitHub
[go: up one dir, main page]

Skip to content

Commit 669b167

Browse files
feature #48992 [HttpKernel] Introduce pinnable value resolvers with #[ValueResolver] and #[AsPinnedValueResolver] (MatTheCat)
This PR was merged into the 6.3 branch. Discussion ---------- [HttpKernel] Introduce pinnable value resolvers with `#[ValueResolver]` and `#[AsPinnedValueResolver]` | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Fix #48927 | License | MIT | Doc PR | symfony/symfony-docs#17763 Introducing a new `ValueResolver` attribute, which allows to - “pin” a value resolver to an argument, meaning only said resolver will be called - prevent a resolver to be called for an argument Every existing resolver-related attribute (`MapEntity`, `CurrentUser`…) now extends `ValueResolver`. Each `controller.argument_value_resolver` tag is added a `name` attribute, which is the resolver’s FQCN. This is the first argument `ValueResolver` expects. A new `AsPinnedValueResolver` attribute is added for autoconfiguration, adding the `controller.pinned_value_resolver` tag. Such resolvers can only be “pinned”, meaning they won’t ever be called for an argument missing the `ValueResolver` attribute. Commits ------- 245485c2a7 [HttpKernel] Introduce pinnable value resolvers with `#[ValueResolver]` and `#[AsPinnedValueResolver]`
2 parents d9c3416 + 8dba7c8 commit 669b167

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Attribute/MapEntity.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@
1111

1212
namespace Symfony\Bridge\Doctrine\Attribute;
1313

14+
use Symfony\Bridge\Doctrine\ArgumentResolver\EntityValueResolver;
15+
use Symfony\Component\HttpKernel\Attribute\ValueResolver;
16+
1417
/**
1518
* Indicates that a controller argument should receive an Entity.
1619
*/
1720
#[\Attribute(\Attribute::TARGET_PARAMETER)]
18-
class MapEntity
21+
class MapEntity extends ValueResolver
1922
{
2023
public function __construct(
2124
public ?string $class = null,
@@ -26,8 +29,10 @@ public function __construct(
2629
public ?bool $stripNull = null,
2730
public array|string|null $id = null,
2831
public ?bool $evictCache = null,
29-
public bool $disabled = false,
32+
bool $disabled = false,
33+
string $resolver = EntityValueResolver::class,
3034
) {
35+
parent::__construct($resolver, $disabled);
3136
}
3237

3338
public function withDefaults(self $defaults, ?string $class): static

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"symfony/config": "^5.4|^6.0",
3131
"symfony/dependency-injection": "^6.2",
3232
"symfony/form": "^5.4.21|^6.2.7",
33-
"symfony/http-kernel": "^6.2",
33+
"symfony/http-kernel": "^6.3",
3434
"symfony/messenger": "^5.4|^6.0",
3535
"symfony/doctrine-messenger": "^5.4|^6.0",
3636
"symfony/property-access": "^5.4|^6.0",

0 commit comments

Comments
 (0)
0