Skip to content

Commit 7e5422b

Browse files
committed
Multi prefixs support
1 parent e816109 commit 7e5422b

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

packages/router/src/RouteDiscovery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ public function discover(DiscoveryLocation $location, ClassReflector $class): vo
2727

2828
foreach ($routeAttributes as $routeAttribute) {
2929
$decorators = [
30-
...$method->getDeclaringClass()->getAttributes(RouteDecorator::class),
3130
...$method->getAttributes(RouteDecorator::class),
31+
...$method->getDeclaringClass()->getAttributes(RouteDecorator::class),
3232
];
3333

3434
$route = DiscoveredRoute::fromRoute($routeAttribute, $decorators, $method);

tests/Fixtures/Controllers/PrefixController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#[Prefix('/prefix')]
1010
final class PrefixController
1111
{
12-
#[Get('/endpoint')]
12+
#[Prefix('/method'), Get('/endpoint')]
1313
public function __invoke(): Ok
1414
{
1515
return new Ok();

tests/Integration/Route/RouterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ public function test_stateless_decorator(): void
272272
public function test_prefix_decorator(): void
273273
{
274274
$this->http
275-
->get('/prefix/endpoint')
275+
->get('/prefix/method/endpoint')
276276
->assertOk();
277277
}
278278

tests/Integration/Route/UriGeneratorTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,20 +266,20 @@ public function cannot_add_custom_signature(): void
266266
public function generates_uri_with_prefix_decorator(): void
267267
{
268268
$this->assertSame(
269-
'/prefix/endpoint',
269+
'/prefix/method/endpoint',
270270
$this->generator->createUri(PrefixController::class),
271271
);
272272

273273
$this->assertSame(
274-
'/prefix/endpoint',
274+
'/prefix/method/endpoint',
275275
uri(PrefixController::class),
276276
);
277277
}
278278

279279
#[Test]
280280
public function is_current_uri_with_prefix_decorator(): void
281281
{
282-
$this->http->get('/prefix/endpoint')->assertOk();
282+
$this->http->get('/prefix/method/endpoint')->assertOk();
283283

284284
$this->assertTrue($this->generator->isCurrentUri(PrefixController::class));
285285
}

0 commit comments

Comments
 (0)