-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Updates to DI config for 3.3 #7807
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
Changes from 1 commit
8433fc1
2d11347
105801c
049df7d
9e84572
c45daf4
2636bea
9ab27f0
0e48bd8
6e6ed94
70178d1
45500b3
759e9b2
6de83e2
89e12de
443aec2
bc7088d
ee27765
5452c61
2229fd3
cac3c6c
12c4944
22adfbd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,6 +149,9 @@ and many others that you'll learn about next. | |
via ``$this->get()`` or ``$this->container->get()``. This forces you to write | ||
more robust code to access services, but if you're not use, use ``Controller``. | ||
|
||
.. versionadded:: 3.3 | ||
The ``AbstractController`` class was added in Symfony 3.3. | ||
|
||
.. index:: | ||
single: Controller; Redirecting | ||
|
||
|
@@ -237,6 +240,10 @@ The Symfony templating system and Twig are explained more in the | |
Fetching Services as Arguments | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should addd an anchor for the old headline |
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
.. versionadded:: 3.3 | ||
The ability to type-hint an argument in order to receive a service was added | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
in Symfony 3.3. | ||
|
||
Symfony comes *packed* with a lot of useful objects, called :doc:`services </service_container>`. | ||
These are used for rendering templates, sending emails, querying the database and | ||
any other "work" you can think of. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,9 @@ service's class or interface name. Want to :doc:`log </logging>` something? No p | |
// ... | ||
} | ||
|
||
.. versionadded:: 3.3 | ||
The ability to type-hint a service in order to receive it was added in Symfony 3.3. | ||
|
||
.. _container-debug-container: | ||
|
||
What other services are available? Find out by running: | ||
|
@@ -177,6 +180,10 @@ the service container *how* to instantiate it: | |
// app/config/services.php | ||
// _defaults and loading entire directories is not possible with PHP configuration | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would keep a concrete example here for those who really want to use php: // you have to define your services one-by-one
use AppBundle/Service/MessageGenerator;
$container->autowire(MessageGenerator::class)
->setAutoconfigured(true)
->setPublic(false); |
||
|
||
.. versionadded:: 3.3 | ||
The ``_defaults`` key and ability to load services from a directory were added | ||
in Symfony 3.3. | ||
|
||
That's it! Thanks to the ``AppBundle\`` line and ``resource`` key below it, a service | ||
will be registered for each class in the ``src/AppBundle/Service`` directory (and | ||
the other directories listed). | ||
|
@@ -462,6 +469,11 @@ pass here. No problem! In your configuration, you can explicitly set this argume | |
->setPublic(false) | ||
->setArgument('$adminEmail', '[email protected]'); | ||
|
||
.. versionadded:: 3.3 | ||
The ability to configure an argument by its name (``$adminEmail``) was added | ||
in Symfony 3.3. Previously, you could configure it only by its index (``2`` in | ||
this case). | ||
|
||
Thanks to this, the container will pass ``[email protected]`` as the third argument | ||
to ``__construct`` when creating the ``SiteUpdateManager`` service. The other arguments | ||
will still be autowired. | ||
|
@@ -641,6 +653,9 @@ service whose id is ``monolog.logger.request``. | |
The autoconfigure Option | ||
------------------------ | ||
|
||
.. versionadded:: 3.3 | ||
The ``autoconfigure`` option was added in Symfony 3.3. | ||
|
||
Above, we've set ``autoconfigure: true`` in the ``_defaults`` section so that it | ||
applies to all services defined in that file. With this setting, the container will | ||
automatically apply certain configuration to your services, based on your service's | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would reverse this sentence:
but if you're use to fetch dependencies using the container, use Controller
, wdyt?