File tree Expand file tree Collapse file tree 2 files changed +29
-3
lines changed
Expand file tree Collapse file tree 2 files changed +29
-3
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace MarcoRieser \Livewire \Helpers ;
4+
5+ use Statamic \View \Antlers \Language \Parser \PathParser ;
6+ use Statamic \View \Antlers \Language \Runtime \PathDataManager ;
7+
8+ class DataFetcher
9+ {
10+ public static function getValue (string $ path , array $ context )
11+ {
12+ $ dataManager = app (PathDataManager::class)
13+ ->setIsPaired (false )
14+ ->setReduceFinal (false );
15+
16+ $ variable = app (PathParser::class)->parse ($ path );
17+
18+ [$ resolved , $ result ] = $ dataManager ->getDataWithExistence ($ variable , $ context );
19+
20+ if (! $ resolved ) {
21+ return null ;
22+ }
23+
24+ return $ result ;
25+ }
26+ }
Original file line number Diff line number Diff line change 44
55use Livewire \Features \SupportScriptsAndAssets \SupportScriptsAndAssets ;
66use Livewire \Mechanisms \FrontendAssets \FrontendAssets ;
7- use Statamic \ Support \ Arr ;
7+ use MarcoRieser \ Livewire \ Helpers \ DataFetcher ;
88use Statamic \Support \Str ;
99use Statamic \Tags \Tags ;
1010
@@ -81,9 +81,9 @@ public function computed()
8181 return null ;
8282 }
8383
84- // TODO[mr]: support public properties or methods on objects in nested data (12.04.2025 mr)
84+ $ path -> prepend ( $ property );
8585
86- return Arr:: get ( \Livewire \Livewire::current ()->$ property, $ path -> join ( ' : ' ) );
86+ return DataFetcher:: getValue ( $ path -> join ( ' : ' ), [ $ property => \Livewire \Livewire::current ()->$ property] );
8787 }
8888
8989 /**
You can’t perform that action at this time.
0 commit comments