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

Clarify goals of AbstractController #42422

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions UPGRADE-5.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +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

HttpKernel
----------
Expand Down
1 change: 1 addition & 0 deletions UPGRADE-6.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +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

HttpFoundation
--------------
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +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

5.3
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
use Twig\Environment;

/**
* Provides common features needed in controllers.
* Provides shortcuts for HTTP-related features in controllers.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
Expand Down Expand Up @@ -370,9 +370,13 @@ protected function createFormBuilder($data = null, array $options = []): FormBui
* Shortcut to return the Doctrine Registry service.
*
* @throws \LogicException If DoctrineBundle is not available
*
* @deprecated since 5.4, inject an instance of ManagerRegistry in your controller instead
fabpot marked this conversation as resolved.
Show resolved Hide resolved
*/
protected function getDoctrine(): ManagerRegistry
{
trigger_deprecation('symfony/framework-bundle', '5.4', 'Method "%s()" is deprecated, inject an instance of ManagerRegistry in your controller instead.', __METHOD__);

if (!$this->container->has('doctrine')) {
throw new \LogicException('The DoctrineBundle is not registered in your application. Try running "composer require symfony/orm-pack".');
}
Expand Down Expand Up @@ -426,9 +430,13 @@ protected function isCsrfTokenValid(string $id, ?string $token): bool
* Dispatches a message to the bus.
*
* @param object|Envelope $message The message or the message pre-wrapped in an envelope
*
* @deprecated since 5.4, inject an instance of MessageBusInterface in your controller instead
*/
protected function dispatchMessage(object $message, array $stamps = []): Envelope
{
trigger_deprecation('symfony/framework-bundle', '5.4', 'Method "%s()" is deprecated, inject an instance of MessageBusInterface in your controller instead.', __METHOD__);

if (!$this->container->has('messenger.default_bus')) {
$message = class_exists(Envelope::class) ? 'You need to define the "messenger.default_bus" configuration option.' : 'Try running "composer require symfony/messenger".';
throw new \LogicException('The message bus is not enabled in your application. '.$message);
Expand Down