Skip to content

Commit

Permalink
Allow string-based IDs in the new route caching system
Browse files Browse the repository at this point in the history
  • Loading branch information
Voltra committed Jun 7, 2024
1 parent af0224d commit 5b4c30d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/FilamentFabricatorManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public function getPageUrls(): array
return $this->routesService->getAllUrls();
}

public function getPageUrlFromId(int $id, bool $prefixSlash = false, array $args = []): ?string
public function getPageUrlFromId(int|string $id, bool $prefixSlash = false, array $args = []): ?string
{
/** @var ?PageContract $page */
$page = $this->getPageModel()::query()->find($id);
Expand Down
12 changes: 6 additions & 6 deletions src/Services/PageRoutesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ class PageRoutesService
/**
* Get the ID of the Page model to which the given URI is associated, -1 if non matches
*
* @return int The page's ID, or -1 on failure
* @return int|string The page's ID, or -1 on failure
*/
public function getPageIdFromUri(string $uri): int
public function getPageIdFromUri(string $uri): int|string
{
// Query the (URI -> ID) mapping based on the user provided URI.
// The mapping expect a URI that starts with a /
Expand Down Expand Up @@ -135,7 +135,7 @@ public function getAllUrls(): array
/**
* Get the URI -> ID mapping
*
* @return array<string, int>
* @return array<string, int|string>
*/
protected function getUriToIdMapping(): array
{
Expand Down Expand Up @@ -164,7 +164,7 @@ protected function getUriToIdMapping(): array
/**
* Get the ID -> URI[] mapping
*
* @return array<int, string[]>
* @return array<int|string, string[]>
*/
protected function getIdToUrisMapping(): array
{
Expand Down Expand Up @@ -305,7 +305,7 @@ protected function forgetPageLocalCache(Page $page)
/**
* Completely replaced the cached ID -> URI[] mapping
*
* @param array<int, string[]> $idToUriMapping
* @param array<int|string, string[]> $idToUriMapping
*/
protected function replaceIdToUriMapping(array $idToUriMapping): void
{
Expand All @@ -319,7 +319,7 @@ protected function replaceIdToUriMapping(array $idToUriMapping): void
/**
* Completely replace the cached URI -> ID mapping
*
* @param array<string, int> $uriToIdMapping
* @param array<string, int|string> $uriToIdMapping
*/
protected function replaceUriToIdMapping(array $uriToIdMapping): void
{
Expand Down

0 comments on commit 5b4c30d

Please sign in to comment.