Skip to content
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

[FrameworkBundle] Deprecate AbstractController::get() and has() #42442

Merged
merged 1 commit into from Aug 9, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion UPGRADE-5.4.md
Expand Up @@ -17,7 +17,7 @@ FrameworkBundle

* Deprecate the `AdapterInterface` autowiring alias, use `CacheItemPoolInterface` instead
* Deprecate the public `profiler` service to private
* Deprecate `getDoctrine()` and `dispatchMessage()` in `AbstractController`, use method/constructor injection instead
* Deprecate `get()`, `has()`, `getDoctrine()`, and `dispatchMessage()` in `AbstractController`, use method/constructor injection instead

HttpKernel
----------
Expand Down
2 changes: 1 addition & 1 deletion UPGRADE-6.0.md
Expand Up @@ -101,7 +101,7 @@ FrameworkBundle
* Remove option `--xliff-version` of the `translation:update` command, use e.g. `--output-format=xlf20` instead
* Remove option `--output-format` of the `translation:update` command, use e.g. `--output-format=xlf20` instead
* Remove the `AdapterInterface` autowiring alias, use `CacheItemPoolInterface` instead
* Remove `getDoctrine()` and `dispatchMessage()` in `AbstractController`, use method/constructor injection instead
* Remove `get()`, `has()`, `getDoctrine()`, and `dispatchMessage()` in `AbstractController`, use method/constructor injection instead

HttpFoundation
--------------
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Expand Up @@ -7,7 +7,7 @@ CHANGELOG
* Add autowiring alias for `HttpCache\StoreInterface`
* Deprecate the `AdapterInterface` autowiring alias, use `CacheItemPoolInterface` instead
* Deprecate the public `profiler` service to private
* Deprecate `getDoctrine()` and `dispatchMessage()` in `AbstractController`, use method/constructor injection instead
* Deprecate `get()`, `has()`, `getDoctrine()`, and `dispatchMessage()` in `AbstractController`, use method/constructor injection instead

5.3
---
Expand Down
Expand Up @@ -96,31 +96,39 @@ public static function getSubscribedServices()
'session' => '?'.SessionInterface::class,
'security.authorization_checker' => '?'.AuthorizationCheckerInterface::class,
'twig' => '?'.Environment::class,
'doctrine' => '?'.ManagerRegistry::class,
'doctrine' => '?'.ManagerRegistry::class, // to be removed in 6.0
'form.factory' => '?'.FormFactoryInterface::class,
'security.token_storage' => '?'.TokenStorageInterface::class,
'security.csrf.token_manager' => '?'.CsrfTokenManagerInterface::class,
'parameter_bag' => '?'.ContainerBagInterface::class,
'message_bus' => '?'.MessageBusInterface::class,
'messenger.default_bus' => '?'.MessageBusInterface::class,
'message_bus' => '?'.MessageBusInterface::class, // to be removed in 6.0
'messenger.default_bus' => '?'.MessageBusInterface::class, // to be removed in 6.0
];
}

/**
* Returns true if the service id is defined.
*
* @deprecated since 5.4, use method or constructor injection in your controller instead
*/
protected function has(string $id): bool
{
trigger_deprecation('symfony/framework-bundle', '5.4', 'Method "%s()" is deprecated, use method or constructor injection in your controller instead.', __METHOD__);

return $this->container->has($id);
}

/**
* Gets a container service by its id.
*
* @return object The service
*
* @deprecated since 5.4, use method or constructor injection in your controller instead
*/
protected function get(string $id): object
{
trigger_deprecation('symfony/framework-bundle', '5.4', 'Method "%s()" is deprecated, use method or constructor injection in your controller instead.', __METHOD__);

return $this->container->get($id);
}

Expand Down
Expand Up @@ -601,6 +601,9 @@ public function testCreateFormBuilder()
$this->assertEquals($formBuilder, $controller->createFormBuilder('foo'));
}

/**
* @group legacy
*/
public function testGetDoctrine()
{
$doctrine = $this->createMock(ManagerRegistry::class);
Expand Down