This repository was archived by the owner on Jan 27, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2727 'classes ' => [
2828 \Jonassiewertsen \Livewire \Synthesizers \EntryCollectionSynthesizer::class,
2929 \Jonassiewertsen \Livewire \Synthesizers \EntrySynthesizer::class,
30+ \Jonassiewertsen \Livewire \Synthesizers \ValueSynthesizer::class,
3031 ],
3132 ],
3233
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Jonassiewertsen \Livewire \Synthesizers ;
4+
5+ use Livewire \Mechanisms \HandleComponents \Synthesizers \Synth ;
6+ use Statamic \Fields \Value ;
7+
8+ use function Livewire \invade ;
9+
10+ class ValueSynthesizer extends Synth
11+ {
12+ public static $ key = 'statamic-value ' ;
13+
14+ public static function match ($ target )
15+ {
16+ return $ target instanceof Value;
17+ }
18+
19+ public function dehydrate ($ target , $ dehydrateChild )
20+ {
21+ $ value = invade ($ target );
22+
23+ $ data = [
24+ 'value ' => $ value ->raw ,
25+ 'handle ' => $ value ->handle ,
26+ 'fieldtype ' => $ value ->fieldtype ,
27+ 'augmentable ' => $ value ->augmentable ,
28+ 'shallow ' => $ value ->shallow ,
29+ ];
30+
31+ foreach ($ data as $ key => $ child ) {
32+ $ data [$ key ] = $ dehydrateChild ($ key , $ child );
33+ }
34+
35+ return [$ data , []];
36+ }
37+
38+ public function hydrate ($ value , $ meta , $ hydrateChild )
39+ {
40+ foreach ($ value as $ key => $ child ) {
41+ $ value [$ key ] = $ hydrateChild ($ key , $ child );
42+ }
43+
44+ return new Value (...$ value );
45+ }
46+ }
You can’t perform that action at this time.
0 commit comments