This repository was archived by the owner on Jan 27, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 27
27
'classes ' => [
28
28
\Jonassiewertsen \Livewire \Synthesizers \EntryCollectionSynthesizer::class,
29
29
\Jonassiewertsen \Livewire \Synthesizers \EntrySynthesizer::class,
30
+ \Jonassiewertsen \Livewire \Synthesizers \FieldSynthesizer::class,
30
31
\Jonassiewertsen \Livewire \Synthesizers \FieldtypeSynthesizer::class,
31
32
\Jonassiewertsen \Livewire \Synthesizers \ValueSynthesizer::class,
32
33
],
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 \Field ;
7
+
8
+ class FieldSynthesizer extends Synth
9
+ {
10
+ public static $ key = 'statamic-field ' ;
11
+
12
+ public static function match ($ target )
13
+ {
14
+ return $ target instanceof Field;
15
+ }
16
+
17
+ public function dehydrate ($ target , $ dehydrateChild )
18
+ {
19
+ $ data = [
20
+ 'handle ' => $ target ->handle (),
21
+ 'config ' => $ target ->config (),
22
+ ];
23
+
24
+ foreach ($ data as $ key => $ child ) {
25
+ $ data [$ key ] = $ dehydrateChild ($ key , $ child );
26
+ }
27
+
28
+ return [$ data , []];
29
+ }
30
+
31
+ public function hydrate ($ value , $ meta , $ hydrateChild )
32
+ {
33
+ foreach ($ value as $ key => $ child ) {
34
+ $ value [$ key ] = $ hydrateChild ($ key , $ child );
35
+ }
36
+
37
+ return new Field (...$ value );
38
+ }
39
+ }
You can’t perform that action at this time.
0 commit comments