|
3 | 3 | namespace MarcoRieser\Livewire\Hooks; |
4 | 4 |
|
5 | 5 | use Livewire\ComponentHook; |
6 | | -use MarcoRieser\Livewire\Contracts\TransformableSynthesizer; |
| 6 | +use MarcoRieser\Livewire\Contracts\Synthesizers\AugmentableSynthesizer; |
7 | 7 |
|
8 | | -class TransformSynthesizers extends ComponentHook |
| 8 | +class SynthesizerAugmentor extends ComponentHook |
9 | 9 | { |
10 | 10 | public function render($view, $data): void |
11 | 11 | { |
12 | 12 | if (! config()->boolean('statamic-livewire.synthesizers.enabled', false)) { |
13 | 13 | return; |
14 | 14 | } |
15 | 15 |
|
16 | | - if (! config()->boolean('statamic-livewire.synthesizers.transform', true)) { |
| 16 | + if (! config()->boolean('statamic-livewire.synthesizers.augmentation', true)) { |
17 | 17 | return; |
18 | 18 | } |
19 | 19 |
|
20 | | - $view->with($this->transformData($data)); |
| 20 | + $view->with($this->augment($data)); |
21 | 21 | } |
22 | 22 |
|
23 | 23 | protected function getMatchingSynthesizer($value): ?string |
24 | 24 | { |
25 | 25 | return collect(config()->array('statamic-livewire.synthesizers.classes', [])) |
26 | | - ->filter(fn (string $synthesizer) => is_subclass_of($synthesizer, TransformableSynthesizer::class) && call_user_func([$synthesizer, 'match'], $value)) |
| 26 | + ->filter(fn (string $synthesizer) => is_subclass_of($synthesizer, AugmentableSynthesizer::class) && call_user_func([$synthesizer, 'match'], $value)) |
27 | 27 | ->first(); |
28 | 28 | } |
29 | 29 |
|
30 | | - protected function transformData(array $data): array |
| 30 | + protected function augment(array $data): array |
31 | 31 | { |
32 | 32 | return collect($data) |
33 | 33 | ->map(function ($value) { |
34 | 34 | $synthesizer = $this->getMatchingSynthesizer($value); |
35 | 35 |
|
36 | | - return $synthesizer ? call_user_func([$synthesizer, 'transform'], $value) : $value; |
| 36 | + return $synthesizer ? call_user_func([$synthesizer, 'augment'], $value) : $value; |
37 | 37 | }) |
38 | 38 | ->all(); |
39 | 39 | } |
|
0 commit comments