Skip to content

Commit 13e25ca

Browse files
[Routing] Simplify importing routes defined on controller services
1 parent 8ceced3 commit 13e25ca

File tree

5 files changed

+8
-12
lines changed

5 files changed

+8
-12
lines changed

src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,13 @@ private function configureRoutes(RoutingConfigurator $routes): void
7979
$routes->import($configDir.'/{routes}/'.$this->environment.'/*.{php,yaml}');
8080
$routes->import($configDir.'/{routes}/*.{php,yaml}');
8181

82+
$routes->import('routing.controllers');
83+
8284
if (is_file($this->getConfigDir().'/routes.yaml')) {
8385
$routes->import($configDir.'/routes.yaml');
8486
} else {
8587
$routes->import($configDir.'/{routes}.php');
8688
}
87-
88-
if ($fileName = (new \ReflectionObject($this))->getFileName()) {
89-
$routes->import($fileName, 'attribute');
90-
}
9189
}
9290

9391
/**

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/reference.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,7 @@ public static function config(array $config): array
184184
*
185185
* return Routes::config([
186186
* 'controllers' => [
187-
* 'resource' => 'attributes',
188-
* 'type' => 'tagged_services',
187+
* 'resource' => 'routing.controllers',
189188
* ],
190189
* ]);
191190
* ```

src/Symfony/Component/Routing/Loader/AttributeServicesLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ public function load(mixed $resource, ?string $type = null): RouteCollection
4242

4343
public function supports(mixed $resource, ?string $type = null): bool
4444
{
45-
return 'tagged_services' === $type && 'attributes' === $resource;
45+
return 'routing.controllers' === $resource;
4646
}
4747
}

src/Symfony/Component/Routing/Loader/Configurator/RoutesReference.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
*
2727
* return Routes::config([
2828
* 'controllers' => [
29-
* 'resource' => 'attributes',
30-
* 'type' => 'tagged_services',
29+
* 'resource' => 'routing.controllers',
3130
* ],
3231
* ]);
3332
* ```

src/Symfony/Component/Routing/Tests/Loader/AttributeServicesLoaderTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public function testSupports()
2626

2727
$this->assertFalse($loader->supports('attributes', null));
2828
$this->assertFalse($loader->supports('attributes', 'attribute'));
29-
$this->assertFalse($loader->supports('other', 'tagged_services'));
30-
$this->assertTrue($loader->supports('attributes', 'tagged_services'));
29+
$this->assertFalse($loader->supports('other', 'routing.controllers'));
30+
$this->assertTrue($loader->supports('routing.controllers'));
3131
}
3232

3333
public function testDelegatesToAttributeLoaderAndMergesCollections()
@@ -47,7 +47,7 @@ public function testDelegatesToAttributeLoaderAndMergesCollections()
4747
$attributeLoader->setResolver($resolver);
4848
$servicesLoader->setResolver($resolver);
4949

50-
$collection = $servicesLoader->load('attributes', 'tagged_services');
50+
$collection = $servicesLoader->load('routing.controllers');
5151

5252
$this->assertArrayHasKey('action', $collection->all());
5353
$this->assertArrayHasKey('put', $collection->all());

0 commit comments

Comments
 (0)