Skip to content

Commit

Permalink
[4.x] Cache Blueprint columns (statamic#8840)
Browse files Browse the repository at this point in the history
Co-authored-by: Jason Varga <[email protected]>
  • Loading branch information
Jonas Siewertsen and jasonvarga authored Oct 20, 2023
1 parent 00cb12e commit 329000b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Fields/Blueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class Blueprint implements Arrayable, ArrayAccess, Augmentable, QueryableValue
protected $ensuredFields = [];
protected $afterSaveCallbacks = [];
protected $withEvents = true;
private ?Columns $columns = null;

public function setHandle(string $handle)
{
Expand Down Expand Up @@ -359,6 +360,10 @@ public function field($field)

public function columns()
{
if ($this->columns) {
return $this->columns;
}

$columns = $this->fields()
->all()
->values()
Expand All @@ -375,7 +380,7 @@ public function columns()
})
->keyBy('field');

return new Columns($columns);
return $this->columns = new Columns($columns);
}

public function isEmpty(): bool
Expand Down

0 comments on commit 329000b

Please sign in to comment.