Skip to content

Commit

Permalink
[5.x] Cache fieldtypes config fields (#10325)
Browse files Browse the repository at this point in the history
Co-authored-by: jasonvarga <[email protected]>
Co-authored-by: Duncan McClean <[email protected]>
  • Loading branch information
3 people authored Jun 20, 2024
1 parent c687bb2 commit e06d9cc
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Fields/Fieldtype.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Contracts\Support\Arrayable;
use Statamic\Extend\HasHandle;
use Statamic\Extend\RegistersItself;
use Statamic\Facades\Blink;
use Statamic\Facades\GraphQL;
use Statamic\Query\Scopes\Filters\Fields\FieldtypeFilter;
use Statamic\Statamic;
Expand Down Expand Up @@ -238,6 +239,10 @@ private function configFieldsUseSections()

public function configFields(): Fields
{
if ($cached = Blink::get($blink = 'config-fields-'.$this->handle())) {
return $cached;
}

$fields = collect($this->configFieldItems());

if ($this->configFieldsUseSections()) {
Expand All @@ -250,7 +255,11 @@ public function configFields(): Fields
return compact('handle', 'field');
});

return new ConfigFields($fields);
$fields = new ConfigFields($fields);

Blink::put($blink, $fields);

return $fields;
}

protected function configFieldItems(): array
Expand Down

0 comments on commit e06d9cc

Please sign in to comment.