1010namespace Respect \Validation \Message ;
1111
1212use Respect \Validation \Exceptions \ComponentException ;
13- use Respect \Validation \Result ;
1413use Respect \Validation \FailedResultIterator ;
14+ use Respect \Validation \Result ;
1515
1616use function array_filter ;
1717use function array_reduce ;
@@ -103,7 +103,7 @@ public function array(Result $result, array $templates, Translator $translator):
103103 $ deduplicatedChildren = new FailedResultIterator ($ result );
104104 if (count ($ deduplicatedChildren ) === 0 || $ this ->isFinalTemplate ($ result , $ selectedTemplates )) {
105105 return [
106- $ result ->getDeepestPath () ?? $ result ->id => $ this ->renderer ->render (
106+ $ result ->path ?->getDeepest()-> value ?? $ result ->id => $ this ->renderer ->render (
107107 $ this ->getTemplated ($ result ->withDeepestPath (), $ selectedTemplates ),
108108 $ translator
109109 ),
@@ -112,7 +112,7 @@ public function array(Result $result, array $templates, Translator $translator):
112112
113113 $ messages = [];
114114 foreach ($ deduplicatedChildren as $ child ) {
115- $ key = $ child-> getDeepestPath () ?? $ child ->id ;
115+ $ key = $ child?->path?->getDeepest()-> value ?? $ child ->id ;
116116 $ messages [$ key ] = $ this ->array (
117117 $ this ->resultWithPath ($ result , $ child ),
118118 $ this ->selectTemplates ($ child , $ selectedTemplates ),
@@ -139,7 +139,7 @@ public function array(Result $result, array $templates, Translator $translator):
139139 return $ messages ;
140140 }
141141
142- public function resultWithPath (Result $ parent , Result $ child ): Result
142+ private function resultWithPath (Result $ parent , Result $ child ): Result
143143 {
144144 if ($ parent ->path !== null && $ child ->path !== null && $ child ->path !== $ parent ->path ) {
145145 return $ child ->withPath ($ parent ->path );
@@ -194,7 +194,7 @@ private function getTemplated(Result $result, array $templates): Result
194194 return $ result ;
195195 }
196196
197- foreach ([$ result ->path , $ result ->name , $ result ->id , '__root__ ' ] as $ key ) {
197+ foreach ([$ result ->path ?->value , $ result ->name , $ result ->id , '__root__ ' ] as $ key ) {
198198 if (!isset ($ templates [$ key ])) {
199199 continue ;
200200 }
@@ -216,7 +216,7 @@ private function getTemplated(Result $result, array $templates): Result
216216 */
217217 private function isFinalTemplate (Result $ result , array $ templates ): bool
218218 {
219- $ keys = [$ result ->path , $ result ->name , $ result ->id ];
219+ $ keys = [$ result ->path ?->value , $ result ->name , $ result ->id ];
220220 foreach ($ keys as $ key ) {
221221 if (isset ($ templates [$ key ]) && is_string ($ templates [$ key ])) {
222222 return true ;
@@ -243,7 +243,7 @@ private function isFinalTemplate(Result $result, array $templates): bool
243243 */
244244 private function selectTemplates (Result $ result , array $ templates ): array
245245 {
246- foreach ([$ result ->path , $ result ->name , $ result ->id ] as $ key ) {
246+ foreach ([$ result ->path ?->value , $ result ->name , $ result ->id ] as $ key ) {
247247 if (isset ($ templates [$ key ]) && is_array ($ templates [$ key ])) {
248248 return $ templates [$ key ];
249249 }
0 commit comments