8000 [HttpKernel] Deprecate single-colon notation for controllers by chalasr · Pull Request #36257 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[HttpKernel] Deprecate single-colon notation for controllers #36257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions UPGRADE-5.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ HttpFoundation
`__construct()` instead)
* Made the Mime component an optional dependency

HttpKernel
----------

* Deprecated support for `service:action` syntax to reference controllers. Use `serviceOrFqcn::method` instead.

Mailer
------

Expand Down
5 changes: 5 additions & 0 deletions UPGRADE-6.0.md
10000
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ HttpFoundation
`RedirectResponse::create()`, and `StreamedResponse::create()` methods (use
`__construct()` instead)

HttpKernel
----------

* Removed support for `service:action` syntax to reference controllers. Use `serviceOrFqcn::method` instead.

Messenger
---------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function testPanelActionWithLatestToken()
$client->request('GET', '/');
$client->request('GET', '/_profiler/latest');

$this->assertStringContainsString('kernel:homepageController', $client->getResponse()->getContent());
$this->assertStringContainsString('kernel::homepageController', $client->getResponse()->getContent());
}

public function testPanelActionWithoutValidToken()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected function configureRoutes(RoutingConfigurator $routes)
{
$routes->import(__DIR__.'/../../Resources/config/routing/profiler.xml')->prefix('/_profiler');
$routes->import(__DIR__.'/../../Resources/config/routing/wdt.xml')->prefix('/_wdt');
$routes->add('_', '/')->controller('kernel:homepageController');
$routes->add('_', '/')->controller('kernel::homepageController');
}

protected function configureContainer(ContainerBuilder $containerBuilder, LoaderInterface $loader)
Expand Down
7 changes: 4 additions & 3 deletions src/Symfony/Component/HttpKernel/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ CHANGELOG
5.1.0
-----

* deprecated support for `service:action` syntax to reference controllers, use `serviceOrFqcn::method` instead
* allowed using public aliases to reference controllers
* added session usage reporting when the `_stateless` attribute of the request is set to `true`

5.0.0
-----

* removed support for getting the container from a non-booted kernel
* removed the first and second constructor argument of `ConfigDataCollector`
* removed `ConfigDataCollector::getApplicationName()`
* removed the first and second constructor argument of `ConfigDataCollector`
* removed `ConfigDataCollector::getApplicationName()`
* removed `ConfigDataCollector::getApplicationVersion()`
* removed support for `Symfony\Component\Templating\EngineInterface` in `HIncludeFragmentRenderer`, use a `Twig\Environment` only
* removed `TranslatorListener` in favor of `LocaleAwareListener`
Expand All @@ -24,7 +25,7 @@ CHANGELOG
* removed `GetResponseForControllerResultEvent`, use `ViewEvent` instead
* removed `GetResponseForExceptionEvent`, use `ExceptionEvent` instead
* removed `PostResponseEvent`, use `TerminateEvent` instead
* removed `SaveSessionListener` in favor of `AbstractSessionListener`
* removed `SaveSessionListener` in favor of `AbstractSessionListener`
* removed `Client`, use `HttpKernelBrowser` instead
* added method `getProjectDir()` to `KernelInterface`
* removed methods `serialize` and `unserialize` from `DataCollector`, store the serialized state in the data property instead
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Symfony\Component\DependencyInjection\Container;

/**
* A controller resolver searching for a controller in a psr-11 container when using the "service:method" notation.
* A controller resolver searching for a controller in a psr-11 container when using the "service::method" notation.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Maxime Steinhausser <maxime.steinhausser@gmail.com>
Expand All @@ -36,7 +36,7 @@ protected function createController(string $controller)
{
if (1 === substr_count($controller, ':')) {
$controller = str_replace(':', '::', $controller);
// TODO deprecate this in 5.1
trigger_deprecation('symfony/http-kernel', '5.1', 'Referencing controllers with a single colon is deprecated. Use "%s" instead.', $controller);
}

return parent::createController($controller);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

class ContainerControllerResolverTest extends ControllerResolverTest
{
/**
* @group legacy
* @expectedDeprecation Since symfony/http-kernel 5.1: Referencing controllers with a single colon is deprecated. Use "foo::action" instead.
*/
public function testGetControllerServiceWithSingleColon()
{
$service = new ControllerTestService('foo');
Expand Down Expand Up @@ -145,7 +149,6 @@ public function getControllers()
{
return [
['\\'.ControllerTestService::class.'::action'],
['\\'.ControllerTestService::class.':action'],
];
}

Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Component/HttpKernel/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
],
"require": {
"php": "^7.2.5",
"symfony/deprecation-contracts": "^2.1",
"symfony/error-handler": "^4.4|^5.0",
"symfony/event-dispatcher": "^5.0",
"symfony/http-foundation": "^4.4|^5.0",
Expand Down
0