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 \FieldtypeSynthesizer::class,
3031 \Jonassiewertsen \Livewire \Synthesizers \ValueSynthesizer::class,
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 \Fieldtype ;
7+
8+ class FieldtypeSynthesizer extends Synth
9+ {
10+ public static $ key = 'statamic-fieldtype ' ;
11+
12+ public static function match ($ target )
13+ {
14+ return $ target instanceof Fieldtype;
15+ }
16+
17+ public function dehydrate ($ target , $ dehydrateChild )
18+ {
19+ $ data = [
20+ 'field ' => $ target ->field (),
21+ ];
22+
23+ foreach ($ data as $ key => $ child ) {
24+ $ data [$ key ] = $ dehydrateChild ($ key , $ child );
25+ }
26+
27+ return [
28+ $ data ,
29+ ['class ' => get_class ($ target )],
30+ ];
31+ }
32+
33+ public function hydrate ($ value , $ meta , $ hydrateChild )
34+ {
35+ foreach ($ value as $ key => $ child ) {
36+ $ value [$ key ] = $ hydrateChild ($ key , $ child );
37+ }
38+
39+ return app ($ meta ['class ' ])->setField ($ value ['field ' ]);
40+ }
41+ }
You can’t perform that action at this time.
0 commit comments