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 d5c2c30

Browse filesBrowse files
committed
#36544 Allow multiple atPath() on ConstraintViolationBuilder.
1 parent 83b37e8 commit d5c2c30
Copy full SHA for d5c2c30

File tree

Expand file treeCollapse file tree

1 file changed

+19
-15
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+19
-15
lines changed

‎src/Symfony/Component/Validator/Violation/ConstraintViolationBuilder.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Violation/ConstraintViolationBuilder.php
+19-15Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ class ConstraintViolationBuilder implements ConstraintViolationBuilderInterface
3131
private $parameters;
3232
private $root;
3333
private $invalidValue;
34-
private $propertyPath;
34+
private $basePropertyPath;
35+
private $propertyPaths;
3536
private $translator;
3637
private $translationDomain;
3738
private $plural;
@@ -52,7 +53,8 @@ public function __construct(ConstraintViolationList $violations, Constraint $con
5253
$this->message = $message;
5354
$this->parameters = $parameters;
5455
$this->root = $root;
55-
$this->propertyPath = $propertyPath;
56+
$this->basePropertyPath = $propertyPath;
57+
$this->propertyPaths = [];
5658
$this->invalidValue = $invalidValue;
5759
$this->translator = $translator;
5860
$this->translationDomain = $translationDomain;
@@ -64,7 +66,7 @@ public function __construct(ConstraintViolationList $violations, Constraint $con
6466
*/
6567
public function atPath(string $path)
6668
{
67-
$this->propertyPath = PropertyPath::append($this->propertyPath, $path);
69+
$this->propertyPaths[] = PropertyPath::append($this->basePropertyPath, $path);
6870

6971
return $this;
7072
}
@@ -158,17 +160,19 @@ public function addViolation()
158160
);
159161
}
160162

161-
$this->violations->add(new ConstraintViolation(
162-
$translatedMessage,
163-
$this->message,
164-
$this->parameters,
165-
$this->root,
166-
$this->propertyPath,
167-
$this->invalidValue,
168-
$this->plural,
169-
$this->code,
170-
$this->constraint,
171-
$this->cause
172-
));
163+
foreach ($this->propertyPaths as $propertyPath) {
164+
$this->violations->add(new ConstraintViolation(
165+
$translatedMessage,
166+
$this->message,
167+
$this->parameters,
168+
$this->root,
169+
$propertyPath,
170+
$this->invalidValue,
171+
$this->plural,
172+
$this->code,
173+
$this->constraint,
174+
$this->cause
175+
));
176+
}
173177
}
174178
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.