Skip to content

Commit 2246f72

Browse files
authored
fix(router): do not discover controller stub (#1453)
1 parent 4aab9ed commit 2246f72

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

packages/router/src/Commands/MakeControllerCommand.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
use Tempest\Console\ConsoleArgument;
88
use Tempest\Console\ConsoleCommand;
99
use Tempest\Core\PublishesFiles;
10+
use Tempest\Discovery\SkipDiscovery;
11+
use Tempest\Generation\ClassManipulator;
1012
use Tempest\Generation\DataObjects\StubFile;
1113
use Tempest\Router\Stubs\ControllerStub;
1214

@@ -39,6 +41,9 @@ public function __invoke(
3941
'dummy-path' => $controllerPath,
4042
'dummy-view' => $controllerView,
4143
],
44+
manipulations: [
45+
fn (ClassManipulator $class) => $class->removeClassAttribute(SkipDiscovery::class),
46+
],
4247
);
4348

4449
$this->console->writeln();

packages/router/src/Stubs/ControllerStub.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55
namespace Tempest\Router\Stubs;
66

7+
use Tempest\Discovery\SkipDiscovery;
78
use Tempest\Router\Get;
89
use Tempest\View\View;
910

1011
use function Tempest\view;
1112

13+
#[SkipDiscovery]
1214
final class ControllerStub
1315
{
1416
#[Get(uri: '/dummy-path')]

tests/Integration/Http/MakeControllerCommandTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public function make_command(
4444

4545
$this->installer
4646
->assertFileExists($expectedPath)
47+
->assertFileNotContains($expectedPath, 'SkipDiscovery')
4748
->assertFileContains($expectedPath, 'namespace ' . $expectedNamespace . ';');
4849
}
4950

0 commit comments

Comments
 (0)