Skip to content

Commit

Permalink
fix: allow prefixing route names
Browse files Browse the repository at this point in the history
  • Loading branch information
SychO9 committed Oct 25, 2024
1 parent 38585cf commit 3af78c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions framework/core/src/Api/ApiServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ protected function populateRoutes(RouteCollection $routes, Container $container)
$path = rtrim("/$type$endpoint->path", '/');
$name = "$type.$endpoint->name";

if ($prefix = $resource->routeNamePrefix()) {
$name = "$prefix.$name";
}

$routes->addRoute($method, $path, $name, $factory->toApiResource($resource::class, $endpoint->name));
}
}
Expand Down
5 changes: 5 additions & 0 deletions framework/core/src/Api/Resource/AbstractResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,9 @@ public function id(Context $context): ?string
{
return $context->extractIdFromPath($context);
}

public function routeNamePrefix(): ?string
{
return null;
}
}

0 comments on commit 3af78c1

Please sign in to comment.