Skip to content

Commit 80be008

Browse files
committed
Rename transformation to augmentation
1 parent 164b6f0 commit 80be008

13 files changed

+41
-41
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,8 @@ To make it work, you need to enable that feature first.
329329
2. Select `statamic-livewire` in the list
330330
3. Enable synthesizers
331331
332-
#### Transformation
333-
By default, the Synthesizers transform (augment) the data before it gets passed into the view. You can disable this by setting `synthesizers.transform` to `false` in your published `config/statamic-livewire.php` config.
332+
#### Augmentation
333+
By default, the Synthesizers augment the data before it gets passed into the antlers view. You can disable this by setting `synthesizers.augmentation` to `false` in your published `config/statamic-livewire.php` config.
334334
335335
### Entangle: Sharing State Between Livewire And Alpine
336336
In case you want to share state between Livewire and Alpine, there is a Blade directive called `@entangle`. To be usable with Antlers, we do provide a dedicated tag:

config/statamic-livewire.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
\MarcoRieser\Livewire\Synthesizers\ValueSynthesizer::class,
5454
],
5555

56-
'transform' => true,
56+
'augmentation' => true,
5757
],
5858

5959
/*
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace MarcoRieser\Livewire\Contracts\Synthesizers;
4+
5+
interface AugmentableSynthesizer
6+
{
7+
public static function augment($target): mixed;
8+
}

src/Contracts/TransformableSynthesizer.php

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,37 @@
33
namespace MarcoRieser\Livewire\Hooks;
44

55
use Livewire\ComponentHook;
6-
use MarcoRieser\Livewire\Contracts\TransformableSynthesizer;
6+
use MarcoRieser\Livewire\Contracts\Synthesizers\AugmentableSynthesizer;
77

8-
class TransformSynthesizers extends ComponentHook
8+
class SynthesizerAugmentor extends ComponentHook
99
{
1010
public function render($view, $data): void
1111
{
1212
if (! config()->boolean('statamic-livewire.synthesizers.enabled', false)) {
1313
return;
1414
}
1515

16-
if (! config()->boolean('statamic-livewire.synthesizers.transform', true)) {
16+
if (! config()->boolean('statamic-livewire.synthesizers.augmentation', true)) {
1717
return;
1818
}
1919

20-
$view->with($this->transformData($data));
20+
$view->with($this->augment($data));
2121
}
2222

2323
protected function getMatchingSynthesizer($value): ?string
2424
{
2525
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))
2727
->first();
2828
}
2929

30-
protected function transformData(array $data): array
30+
protected function augment(array $data): array
3131
{
3232
return collect($data)
3333
->map(function ($value) {
3434
$synthesizer = $this->getMatchingSynthesizer($value);
3535

36-
return $synthesizer ? call_user_func([$synthesizer, 'transform'], $value) : $value;
36+
return $synthesizer ? call_user_func([$synthesizer, 'augment'], $value) : $value;
3737
})
3838
->all();
3939
}

src/ServiceProvider.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Livewire\Livewire;
88
use Livewire\Mechanisms\HandleComponents\Synthesizers\Synth;
99
use MarcoRieser\Livewire\Hooks\ComputedPropertiesAutoloader;
10-
use MarcoRieser\Livewire\Hooks\TransformSynthesizers;
10+
use MarcoRieser\Livewire\Hooks\SynthesizerAugmentor;
1111
use MarcoRieser\Livewire\Http\Middleware\ResolveCurrentSiteByLivewireUrl;
1212
use Statamic\Http\Middleware\Localize;
1313
use Statamic\Providers\AddonServiceProvider;
@@ -22,7 +22,7 @@ public function register(): void
2222
{
2323
parent::register();
2424

25-
$this->registerSynthesizerTransformations();
25+
$this->registerSynthesizerAugmentation();
2626
$this->registerComputedPropertiesAutoloader();
2727
}
2828

@@ -66,9 +66,9 @@ protected function bootSynthesizers(): void
6666
->each(fn (string $synthesizer) => Livewire::propertySynthesizer($synthesizer));
6767
}
6868

69-
protected function registerSynthesizerTransformations(): void
69+
protected function registerSynthesizerAugmentation(): void
7070
{
71-
Livewire::componentHook(TransformSynthesizers::class);
71+
Livewire::componentHook(SynthesizerAugmentor::class);
7272
}
7373

7474
protected function registerComputedPropertiesAutoloader(): void

src/Synthesizers/EntryCollectionSynthesizer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
namespace MarcoRieser\Livewire\Synthesizers;
44

55
use Livewire\Mechanisms\HandleComponents\Synthesizers\Synth;
6-
use MarcoRieser\Livewire\Contracts\TransformableSynthesizer;
6+
use MarcoRieser\Livewire\Contracts\Synthesizers\AugmentableSynthesizer;
77
use Statamic\Entries\EntryCollection;
88

9-
class EntryCollectionSynthesizer extends Synth implements TransformableSynthesizer
9+
class EntryCollectionSynthesizer extends Synth implements AugmentableSynthesizer
1010
{
1111
public static string $key = 'slw_entryco';
1212

@@ -15,7 +15,7 @@ public static function match($target): bool
1515
return $target instanceof EntryCollection;
1616
}
1717

18-
public static function transform($target): array
18+
public static function augment($target): array
1919
{
2020
return $target->toAugmentedArray();
2121
}

src/Synthesizers/EntrySynthesizer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
use Illuminate\Support\Arr;
77
use Illuminate\Support\Carbon;
88
use Livewire\Mechanisms\HandleComponents\Synthesizers\Synth;
9-
use MarcoRieser\Livewire\Contracts\TransformableSynthesizer;
9+
use MarcoRieser\Livewire\Contracts\Synthesizers\AugmentableSynthesizer;
1010
use Statamic\Contracts\Entries\Entry as EntryContract;
1111
use Statamic\Facades\Entry;
1212

13-
class EntrySynthesizer extends Synth implements TransformableSynthesizer
13+
class EntrySynthesizer extends Synth implements AugmentableSynthesizer
1414
{
1515
public static string $key = 'slw_entry';
1616

@@ -19,7 +19,7 @@ public static function match($target): bool
1919
return $target instanceof EntryContract;
2020
}
2121

22-
public static function transform($target): array
22+
public static function augment($target): array
2323
{
2424
return $target->toAugmentedArray();
2525
}

src/Synthesizers/FieldSynthesizer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
namespace MarcoRieser\Livewire\Synthesizers;
44

55
use Livewire\Mechanisms\HandleComponents\Synthesizers\Synth;
6-
use MarcoRieser\Livewire\Contracts\TransformableSynthesizer;
6+
use MarcoRieser\Livewire\Contracts\Synthesizers\AugmentableSynthesizer;
77
use Statamic\Fields\Field;
88

99
use function Livewire\invade;
1010

11-
class FieldSynthesizer extends Synth implements TransformableSynthesizer
11+
class FieldSynthesizer extends Synth implements AugmentableSynthesizer
1212
{
1313
public static string $key = 'slw_field';
1414

@@ -17,7 +17,7 @@ public static function match($target): bool
1717
return $target instanceof Field;
1818
}
1919

20-
public static function transform($target): mixed
20+
public static function augment($target): mixed
2121
{
2222
return $target->augment();
2323
}

src/Testing/Concerns/CanManipulateAddonConfig.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ protected function disableSynthesizers(): void
1616
$this->setConfigValue('synthesizers.enabled', false);
1717
}
1818

19-
protected function disableSynthesizerTransform(): void
19+
protected function disableSynthesizerAugmentation(): void
2020
{
21-
$this->setConfigValue('synthesizers.transform', false);
21+
$this->setConfigValue('synthesizers.augmentation', false);
2222
}
2323

24-
protected function enableSynthesizerTransform(): void
24+
protected function enableSynthesizerAugmentation(): void
2525
{
26-
$this->setConfigValue('synthesizers.transform', true);
26+
$this->setConfigValue('synthesizers.augmentation', true);
2727
}
2828

2929
protected function setConfigValue(string $key, $value): void

0 commit comments

Comments
 (0)