@@ -104,7 +104,7 @@ public function array(Result $result, array $templates, Translator $translator):
104104
105105 $ children = [];
106106 foreach ($ this ->extractDeduplicatedChildren ($ result ) as $ child ) {
107- $ childKey = $ child ->path ?? $ child ->id ;
107+ $ childKey = $ child ->path ?? ' __ ' . $ child ->id ;
108108
109109 $ children [$ childKey ] = $ this ->array (
110110 $ child ,
@@ -120,7 +120,7 @@ public function array(Result $result, array $templates, Translator $translator):
120120 }
121121
122122 if (count ($ children ) === 0 || $ this ->isFinalTemplate ($ result , $ selectedTemplates )) {
123- return [$ result ->path ?? $ result ->id => $ messages ['__root ' ]];
123+ return [$ result ->path ?? ' __ ' . $ result ->id => $ messages ['__root ' ]];
124124 }
125125
126126 if ($ result ->path !== null ) {
@@ -172,7 +172,7 @@ private function getTemplated(Result $result, array $templates): Result
172172 return $ result ;
173173 }
174174
175- foreach ([$ result ->path , $ result ->name , $ result ->id , '__root ' ] as $ key ) {
175+ foreach ([$ result ->path , $ result ->name , ' __ ' . $ result ->id , '__root ' ] as $ key ) {
176176 if (!isset ($ templates [$ key ])) {
177177 continue ;
178178 }
@@ -194,7 +194,7 @@ private function getTemplated(Result $result, array $templates): Result
194194 */
195195 private function isFinalTemplate (Result $ result , array $ templates ): bool
196196 {
197- $ keys = [$ result ->path , $ result ->name , $ result ->id ];
197+ $ keys = [$ result ->path , $ result ->name , ' __ ' . $ result ->id ];
198198 foreach ($ keys as $ key ) {
199199 if (isset ($ templates [$ key ]) && is_string ($ templates [$ key ])) {
200200 return true ;
@@ -221,7 +221,7 @@ private function isFinalTemplate(Result $result, array $templates): bool
221221 */
222222 private function selectTemplates (Result $ result , array $ templates ): array
223223 {
224- foreach ([$ result ->path , $ result ->name , $ result ->id ] as $ key ) {
224+ foreach ([$ result ->path , $ result ->name , ' __ ' . $ result ->id ] as $ key ) {
225225 if (isset ($ templates [$ key ]) && is_array ($ templates [$ key ])) {
226226 return $ templates [$ key ];
227227 }
0 commit comments