File tree Expand file tree Collapse file tree 2 files changed +26
-9
lines changed Expand file tree Collapse file tree 2 files changed +26
-9
lines changed Original file line number Diff line number Diff line change @@ -38,15 +38,14 @@ public function execute(
3838 }
3939
4040 if ($ next === true ) {
41- $ fields [$ field ] = new TransformationContext (
42- $ transformationContext ->transformValues ,
43- $ transformationContext ->mapPropertyNames ,
44- $ transformationContext ->wrapExecutionType ,
45- $ transformationContext ->transformers ,
46- depth: $ transformationContext ->depth + 1 ,
47- maxDepth: $ transformationContext ->maxDepth ,
48- throwWhenMaxDepthReached: $ transformationContext ->throwWhenMaxDepthReached ,
49- );
41+ $ fieldTransFormationContext = clone $ transformationContext ;
42+ $ fieldTransFormationContext ->depth ++;
43+ $ fieldTransFormationContext ->includePartials = null ;
44+ $ fieldTransFormationContext ->excludePartials = null ;
45+ $ fieldTransFormationContext ->onlyPartials = null ;
46+ $ fieldTransFormationContext ->exceptPartials = null ;
47+
48+ $ fields [$ field ] = $ fieldTransFormationContext ;
5049 }
5150 }
5251
Original file line number Diff line number Diff line change @@ -1375,3 +1375,21 @@ public static function instance(bool $includeByDefault): self
13751375 ],
13761376 ]);
13771377});
1378+
1379+ it ('can handle custom transformation contexts ' , function () {
1380+ $ data = VisibleFieldsData::instance ();
1381+
1382+ class CustomTransformationContext extends TransformationContext
1383+ {
1384+ };
1385+
1386+ $ visibleFields = app (VisibleDataFieldsResolver::class)->execute (
1387+ $ data ,
1388+ app (DataConfig::class)->getDataClass ($ data ::class),
1389+ new CustomTransformationContext (),
1390+ );
1391+
1392+ expect ($ visibleFields ['single ' ])->toBeInstanceOf (CustomTransformationContext::class);
1393+ expect ($ visibleFields ['nested ' ])->toBeInstanceOf (CustomTransformationContext::class);
1394+ expect ($ visibleFields ['collection ' ])->toBeInstanceOf (CustomTransformationContext::class);
1395+ });
You can’t perform that action at this time.
0 commit comments