Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Commit

Permalink
Allow custom page url in response (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
FluffyDiscord authored Jun 9, 2023
1 parent 6d1d0b9 commit 28e7bdc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Service/Inertia.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@ public function getSsrUrl(): string
return $this->ssrUrl;
}

public function render($component, $props = [], $viewData = [], $context = []): Response
public function render($component, $props = [], $viewData = [], $context = [], $url = null): Response
{
$context = array_merge($this->sharedContext, $context);
$viewData = array_merge($this->sharedViewData, $viewData);
$props = array_merge($this->sharedProps, $props);
$request = $this->requestStack->getCurrentRequest();
$url = $request->getRequestUri();
$url = $url ?? $request->getRequestUri();

$only = array_filter(explode(',', $request->headers->get('X-Inertia-Partial-Data') ?? ''));
$props = ($only && $request->headers->get('X-Inertia-Partial-Component') === $component)
Expand Down
11 changes: 6 additions & 5 deletions Service/InertiaInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ public function getSsrUrl(): string;
public function lazy($callback): LazyProp;

/**
* @param string $component component name
* @param array $props component properties
* @param array $viewData templating view data
* @param array $context serialization context
* @param string $component component name
* @param array $props component properties
* @param array $viewData templating view data
* @param array $context serialization context
* @param string|null $url custom url
*/
public function render($component, $props = [], $viewData = [], $context = []): Response;
public function render($component, $props = [], $viewData = [], $context = [], $url = null): Response;
}

0 comments on commit 28e7bdc

Please sign in to comment.