Skip to content

Commit

Permalink
pint
Browse files Browse the repository at this point in the history
  • Loading branch information
markhuot committed Nov 4, 2023
1 parent 94c5a73 commit 0f58c94
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
7 changes: 2 additions & 5 deletions src/models/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use craft\db\ActiveQuery;
use craft\elements\Asset;
use craft\fields\Assets;
use Illuminate\Support\Collection;
use markhuot\keystone\actions\GetComponentType;
use markhuot\keystone\actions\NormalizeFieldDataForComponent;
use markhuot\keystone\base\AttributeBag;
Expand All @@ -17,8 +16,6 @@
use markhuot\keystone\db\ActiveRecord;
use markhuot\keystone\db\Table;

use function markhuot\craftpest\helpers\test\dd;
use function markhuot\craftpest\helpers\test\dump;
use function markhuot\keystone\helpers\base\app;
use function markhuot\keystone\helpers\base\throw_if;

Expand Down Expand Up @@ -162,7 +159,7 @@ public function eagerLoadRelations()
foreach ($component->getType()->getFieldDefinitions() as $field) {
if ($field->className === Assets::class) {
$assets = collect($component->data->getRaw($field->handle) ?? [])
->map(fn($id) => $assets->get($id))
->map(fn ($id) => $assets->get($id))
->filter();
$component->data->populateRelation($field->handle, $assets);
}
Expand Down Expand Up @@ -255,7 +252,7 @@ public function getProps(): ComponentData
return $this->data;
}

public function getProp(string $key, mixed $default=null)
public function getProp(string $key, mixed $default = null)
{
return $this->getProps()[$key] ?? $default;
}
Expand Down
1 change: 0 additions & 1 deletion src/models/ComponentData.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use markhuot\keystone\db\ActiveRecord;
use markhuot\keystone\db\Table;

use function markhuot\craftpest\helpers\test\dd;
use function markhuot\keystone\helpers\base\throw_if;
use function markhuot\keystone\helpers\data\data_forget;

Expand Down
4 changes: 1 addition & 3 deletions tests/EagerLoadTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
use markhuot\craftpest\factories\Asset;
use markhuot\keystone\models\Component;

use function markhuot\craftpest\helpers\test\dd;

it('eager loads assets', function () {
$fragment = Component::factory()
->type('keystone/fragment')
Expand All @@ -23,4 +21,4 @@
$fragment->getSlot()->each(fn ($c) => $c->getProp('asset')->one());
$this->endBenchmark()
->assertQueryCount(3);
});
});

0 comments on commit 0f58c94

Please sign in to comment.