Skip to content

Commit 98bf4ff

Browse files
committed
minor #10313 Update 3.3-di-changes.rst (DonCallisto)
This PR was submitted for the master branch but it was squashed and merged into the 3.4 branch instead (closes #10313). Discussion ---------- Update 3.3-di-changes.rst Looking at deprecations of 4.2, I noticed that extending `AbstractController` will prevent you from getting the services (even public ones) from container. This should be reported. <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/roadmap for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `master` for features of unreleased versions). --> Commits ------- f16e631 Update 3.3-di-changes.rst
2 parents a0bec48 + f16e631 commit 98bf4ff

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

service_container/3.3-di-changes.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,13 @@ Start by updating the service ids to class names:
585585
account when looking up for services.
586586
Furthermore it is always recommended to check for definition existence
587587
using ``has()`` function.
588+
589+
.. note::
590+
591+
If you get rid of deprecations and extend ``AbstractController`` instead of ``Controller`` for
592+
your controllers, you can skip the rest of this step as `AbstractController` won't provide a
593+
container where you can get the services directly. All services need to be injected as explained
594+
in the :ref:`step 5 of this article <step-5>`.
588595

589596
But, this change will break our app! The old service ids (e.g. ``app.github_notifier``)
590597
no longer exist. The simplest way to fix this is to find all your old service ids
@@ -716,6 +723,8 @@ will be used. If you *don't* have this, the auto-registration feature will try t
716723
register a third ``ApiClient`` service and use that for autowiring (which will fail,
717724
because the class has a non-autowireable argument).
718725

726+
.. _step-5:
727+
719728
Step 5) Cleanup!
720729
~~~~~~~~~~~~~~~~
721730

0 commit comments

Comments
 (0)