Skip to content

Update 3.3-di-changes.rst #9695

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

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
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
8 changes: 8 additions & 0 deletions service_container/3.3-di-changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,12 @@ Start by updating the service ids to class names:
classes (e.g. ``Twig_Extensions_Extension_Intl`` instead of ``Twig\Extensions\IntlExtension``),
  you can't redefine the service as ``Twig_Extensions_Extension_Intl: ~`` and
you must keep the original ``class`` parameter.

.. caution::

If a service is processed by `Compiler Pass`_ you could face a "You have requested a non-existent service" error.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually split lines after the first word that crosses the 72nd character.

To get rid of this, be sure that Compiler Pass is using ``findDefinition`` instead of ``getDefinition`` as the latter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use findDefinition() and getDefinition() (i.e. include the parentheses)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also add a note that it is generally a good idea to check with has() first if there actually is an alias or definition we are looking for.

won't take aliases into account when looking up for services.

But, this change will break our app! The old service ids (e.g. ``app.github_notifier``)
no longer exist. The simplest way to fix this is to find all your old service ids
Expand Down Expand Up @@ -778,3 +784,5 @@ can be autowired. The final configuration looks like this:
You can now take advantage of the new features going forward.

.. _`FrameworkExtension for 3.3.0`: https://github.com/symfony/symfony/blob/7938fdeceb03cc1df277a249cf3da70f0b50eb98/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php#L247-L284

.. _`Compiler Pass`: https://symfony.com/doc/current/service_container/compiler_passes.html
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should use the doc role instead:

If a service is processed by a :doc:`compiler pass </service_container/compiler_passes>` [...]