Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Provide Livewire 3 context" #190

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 9 additions & 32 deletions src/ContextProviders/LaravelLivewireRequestContextProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use Livewire\LivewireManager;
use Livewire\Mechanisms\ComponentRegistry;

class LaravelLivewireRequestContextProvider extends LaravelRequestContextProvider
{
Expand Down Expand Up @@ -41,26 +40,6 @@ public function toArray(): array
/** @return array<string, mixed> */
protected function getLivewireInformation(): array
{
if ($this->request->has('components')) {
$data = [];

foreach ($this->request->get('components') as $component) {
$snapshot = json_decode($component['snapshot'], true);

$class = app(ComponentRegistry::class)->getClass($snapshot['memo']['name']);

$data[] = [
'component_class' => $class ?? null,
'data' => $snapshot['data'],
'memo' => $snapshot['memo'],
'updates' => $this->resolveUpdates($component['updates']),
'calls' => $component['calls'],
];
}

return $data;
}

/** @phpstan-ignore-next-line */
$componentId = $this->request->input('fingerprint.id');

Expand All @@ -77,17 +56,12 @@ protected function getLivewireInformation(): array
$componentClass = null;
}

/** @phpstan-ignore-next-line */
$updates = $this->request->input('updates') ?? [];

return [
[
'component_class' => $componentClass,
'component_alias' => $componentAlias,
'component_id' => $componentId,
'data' => $this->resolveData(),
'updates' => $this->resolveUpdates($updates),
],
'component_class' => $componentClass,
'component_alias' => $componentAlias,
'component_id' => $componentId,
'data' => $this->resolveData(),
'updates' => $this->resolveUpdates(),
];
}

Expand All @@ -112,8 +86,11 @@ protected function resolveData(): array
}

/** @return array<string, mixed> */
protected function resolveUpdates(array $updates): array
protected function resolveUpdates(): array
{
/** @phpstan-ignore-next-line */
$updates = $this->request->input('updates') ?? [];

return array_map(function (array $update) {
$update['payload'] = Arr::except($update['payload'] ?? [], ['id']);

Expand Down
Loading