Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7abc106

Browse filesBrowse 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
Copy full SHA for 7abc106

File tree

Expand file treeCollapse file tree

2 files changed

+8
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+8
-1
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityTest.php
+7Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntity.php
+1-1Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.