File tree Expand file tree Collapse file tree 2 files changed +50
-8
lines changed
src/Symfony/Component/Validator Expand file tree Collapse file tree 2 files changed +50
-8
lines changed Original file line number Diff line number Diff line change @@ -45,8 +45,7 @@ class ExecutionContextManager extends AbstractVisitor implements ExecutionContex
4545 public function __construct (GroupManagerInterface $ groupManager )
4646 {
4747 $ this ->groupManager = $ groupManager ;
48-
49- $ this ->reset ();
48+ $ this ->contextStack = new \SplStack ();
5049 }
5150
5251 public function initialize (ValidatorInterface $ validator )
@@ -95,7 +94,7 @@ public function getCurrentContext()
9594
9695 public function afterTraversal (array $ nodes )
9796 {
98- $ this ->reset ();
97+ $ this ->contextStack = new \ SplStack ();
9998 }
10099
101100 public function enterNode (Node $ node )
@@ -115,9 +114,4 @@ public function leaveNode(Node $node)
115114
116115 $ this ->currentContext ->popNode ();
117116 }
118-
119- private function reset ()
120- {
121- $ this ->contextStack = new \SplStack ();
122- }
123117}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * This file is part of the Symfony package.
5+ *
6+ * (c) Fabien Potencier <[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+ namespace Symfony \Component \Validator \NodeVisitor ;
13+
14+ use Symfony \Component \Validator \Node \ClassNode ;
15+ use Symfony \Component \Validator \Node \Node ;
16+ use Symfony \Component \Validator \ObjectInitializerInterface ;
17+
18+ /**
19+ * @since %%NextVersion%%
20+ * @author Bernhard Schussek <[email protected] > 21+ */
22+ class ObjectInitializer extends AbstractVisitor
23+ {
24+ /**
25+ * @var ObjectInitializerInterface[]
26+ */
27+ private $ initializers ;
28+
29+ public function __construct (array $ initializers )
30+ {
31+ foreach ($ initializers as $ initializer ) {
32+ if (!$ initializer instanceof ObjectInitializerInterface) {
33+ throw new \LogicException ('Validator initializers must implement ObjectInitializerInterface. ' );
34+ }
35+ }
36+
37+ $ this ->initializers = $ initializers ;
38+ }
39+
40+ public function enterNode (Node $ node )
41+ {
42+ if ($ node instanceof ClassNode) {
43+ foreach ($ this ->initializers as $ initializer ) {
44+ $ initializer ->initialize ($ node ->value );
45+ }
46+ }
47+ }
48+ }
You can’t perform that action at this time.
0 commit comments