8000 bug #57405 [DoctrineBridge] fix handling of special "value" constrain… · symfony/symfony@7abc106 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 7abc106

Browse files
committed
bug #57405 [DoctrineBridge] fix handling of special "value" constraint option (xabbuh)
This PR was merged into the 7.1 branch. Discussion ---------- [DoctrineBridge] fix handling of special "value" constraint option | Q | A | ------------- | --- | Branch? | 7.1 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #57396 | License | MIT Commits ------- c2f71af fix handling of special "value" constraint option
2 parents 302938c + c2f71af commit 7abc106

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ public function testAttributeWithGroupsAndPaylod()
6060
self::assertSame('some attached data', $constraint->payload);
6161
self::assertSame(['some_group'], $constraint->groups);
6262
}
63+
64+
public function testValueOptionConfiguresFields()
65+
{
66+
$constraint = new UniqueEntity(['value' => 'email']);
67+
68+
$this->assertSame('email', $constraint->fields);
69+
}
6370
}
6471

6572
#[UniqueEntity(['email'], message: 'myMessage')]

src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function __construct(
6060
$payload = null,
6161
array $options = [],
6262
) {
63-
if (\is_array($fields) && \is_string(key($fields)) && [] === array_diff(array_keys($fields), array_keys(get_class_vars(static::class)))) {
63+
if (\is_array($fields) && \is_string(key($fields)) && [] === array_diff(array_keys($fields), array_merge(array_keys(get_class_vars(static::class)), ['value']))) {
6464
$options = array_merge($fields, $options);
6565
} else {
6666
$options['fields'] = $fields;

0 commit comments

Comments
 (0)
0