Skip to content

Commit dbcb234

Browse files
authored
Fix for vendor prefixed fieldset handles (#339)
1 parent 5fa84f7 commit dbcb234

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/Fields/FieldsetRepository.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Statamic\Facades\Blink;
77
use Statamic\Fields\Fieldset;
88
use Statamic\Fields\FieldsetRepository as StacheRepository;
9+
use Statamic\Support\Str;
910

1011
class FieldsetRepository extends StacheRepository
1112
{
@@ -18,8 +19,14 @@ public function all(): Collection
1819

1920
return $models->map(function ($model) {
2021
return Blink::once("eloquent-fieldset-{$model->handle}", function () use ($model) {
22+
$handle = $model->handle;
23+
24+
if (Str::startsWith($handle, 'vendor.')) {
25+
$handle = Str::of($handle)->after('vendor.')->replaceFirst('.', '::');
26+
}
27+
2128
return (new Fieldset)
22-
->setHandle($model->handle)
29+
->setHandle($handle)
2330
->setContents($model->data);
2431
});
2532
});
@@ -30,6 +37,10 @@ public function find($handle): ?Fieldset
3037
{
3138
$handle = str_replace('/', '.', $handle);
3239

40+
if (Str::startsWith($handle, 'vendor.')) {
41+
$handle = Str::of($handle)->after('vendor.')->replaceFirst('.', '::');
42+
}
43+
3344
return $this->all()->filter(function ($fieldset) use ($handle) {
3445
return $fieldset->handle() == $handle;
3546
})->first();

0 commit comments

Comments
 (0)