Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d58e701

Browse filesBrowse files
committed
Enable controller service with #[Route] attribute instead of #[AsController]
1 parent 79ea49c commit d58e701
Copy full SHA for d58e701

File tree

2 files changed

+7
-1
lines changed
Filter options

2 files changed

+7
-1
lines changed

‎src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ CHANGELOG
1919
* Add DI alias from `ServicesResetterInterface` to `services_resetter`
2020
* Add `methods` argument in `#[IsCsrfTokenValid]` attribute
2121
* Allow configuring the logging channel per type of exceptions
22+
* Enable service argument resolution on classes that use the `#[Route]` attribute,
23+
the `#[AsController]` attribute is no longer required.
2224

2325
7.2
2426
---

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+5-1
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@
164164
use Symfony\Component\RateLimiter\Storage\CacheStorage;
165165
use Symfony\Component\RemoteEvent\Attribute\AsRemoteEventConsumer;
166166
use Symfony\Component\RemoteEvent\RemoteEvent;
167+
use Symfony\Component\Routing\Attribute\Route;
167168
use Symfony\Component\Scheduler\Attribute\AsCronTask;
168169
use Symfony\Component\Scheduler\Attribute\AsPeriodicTask;
169170
use Symfony\Component\Scheduler\Attribute\AsSchedule;
@@ -429,7 +430,7 @@ public function load(array $configs, ContainerBuilder $container): void
429430
}
430431
$loggers[$exception['log_channel']] = new Reference('monolog.logger.'.$exception['log_channel'], ContainerInterface::NULL_ON_INVALID_REFERENCE);
431432
}
432-
433+
433434
$exceptionListener
434435
->replaceArgument(3, $config['exceptions'])
435436
->setArgument(4, $loggers)
@@ -739,6 +740,9 @@ public function load(array $configs, ContainerBuilder $container): void
739740
$container->registerAttributeForAutoconfiguration(AsController::class, static function (ChildDefinition $definition, AsController $attribute): void {
740741
$definition->addTag('controller.service_arguments');
741742
});
743+
$container->registerAttributeForAutoconfiguration(Route::class, static function (ChildDefinition $definition, Route $attribute, \ReflectionClass|\ReflectionMethod $reflection): void {
744+
$definition->addTag('controller.service_arguments');
745+
});
742746
$container->registerAttributeForAutoconfiguration(AsRemoteEventConsumer::class, static function (ChildDefinition $definition, AsRemoteEventConsumer $attribute): void {
743747
$definition->addTag('remote_event.consumer', ['consumer' => $attribute->name]);
744748
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.