Skip to content

Commit 813fdc2

Browse files
committed
Merge branch '2.8' into 3.0
2 parents 61cb386 + e3db793 commit 813fdc2

File tree

5 files changed

+64
-54
lines changed

5 files changed

+64
-54
lines changed

book/controller.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ The controller has a single argument, ``$name``, which corresponds to the
256256
``{name}`` placeholder from the matched route (e.g. ``ryan`` if you go to
257257
``/hello/ryan``). When executing the controller, Symfony matches each argument
258258
with a placeholder from the route. So the value for ``{name}`` is passed
259-
to ``$name``. Just make sure they the name of the placeholder is the
259+
to ``$name``. Just make sure that the name of the placeholder is the
260260
same as the name of the argument variable.
261261

262262
Take the following more-interesting example, where the controller has two

book/service_container.rst

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -292,19 +292,19 @@ Importing Configuration with ``imports``
292292

293293
So far, you've placed your ``app.mailer`` service container definition directly
294294
in the application configuration file (e.g. ``app/config/config.yml``). Of
295-
course, since the ``Mailer`` class itself lives inside the AcmeHelloBundle, it
295+
course, since the ``Mailer`` class itself lives inside the AppBundle, it
296296
makes more sense to put the ``app.mailer`` container definition inside the
297297
bundle as well.
298298

299299
First, move the ``app.mailer`` container definition into a new container resource
300-
file inside AcmeHelloBundle. If the ``Resources`` or ``Resources/config``
300+
file inside AppBundle. If the ``Resources`` or ``Resources/config``
301301
directories don't exist, create them.
302302

303303
.. configuration-block::
304304

305305
.. code-block:: yaml
306306
307-
# src/Acme/HelloBundle/Resources/config/services.yml
307+
# src/AppBundle/Resources/config/services.yml
308308
parameters:
309309
app.mailer.transport: sendmail
310310
@@ -315,7 +315,7 @@ directories don't exist, create them.
315315
316316
.. code-block:: xml
317317
318-
<!-- src/Acme/HelloBundle/Resources/config/services.xml -->
318+
<!-- src/AppBundle/Resources/config/services.xml -->
319319
<?xml version="1.0" encoding="UTF-8" ?>
320320
<container xmlns="http://symfony.com/schema/dic/services"
321321
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -335,7 +335,7 @@ directories don't exist, create them.
335335
336336
.. code-block:: php
337337
338-
// src/Acme/HelloBundle/Resources/config/services.php
338+
// src/AppBundle/Resources/config/services.php
339339
use Symfony\Component\DependencyInjection\Definition;
340340
341341
$container->setParameter('app.mailer.transport', 'sendmail');
@@ -356,7 +356,7 @@ configuration.
356356
357357
# app/config/config.yml
358358
imports:
359-
- { resource: '@AcmeHelloBundle/Resources/config/services.yml' }
359+
- { resource: '@AppBundle/Resources/config/services.yml' }
360360
361361
.. code-block:: xml
362362
@@ -368,23 +368,23 @@ configuration.
368368
http://symfony.com/schema/dic/services/services-1.0.xsd">
369369
370370
<imports>
371-
<import resource="@AcmeHelloBundle/Resources/config/services.xml"/>
371+
<import resource="@AppBundle/Resources/config/services.xml"/>
372372
</imports>
373373
</container>
374374
375375
.. code-block:: php
376376
377377
// app/config/config.php
378-
$loader->import('@AcmeHelloBundle/Resources/config/services.php');
378+
$loader->import('@AppBundle/Resources/config/services.php');
379379
380380
.. include:: /components/dependency_injection/_imports-parameters-note.rst.inc
381381

382382
The ``imports`` directive allows your application to include service container
383383
configuration resources from any other location (most commonly from bundles).
384384
The ``resource`` location, for files, is the absolute path to the resource
385-
file. The special ``@AcmeHelloBundle`` syntax resolves the directory path
386-
of the AcmeHelloBundle bundle. This helps you specify the path to the resource
387-
without worrying later if you move the AcmeHelloBundle to a different directory.
385+
file. The special ``@AppBundle`` syntax resolves the directory path
386+
of the AppBundle bundle. This helps you specify the path to the resource
387+
without worrying later if you move the AppBundle to a different directory.
388388

389389
.. index::
390390
single: Service Container; Extension configuration
@@ -644,7 +644,7 @@ of the new ``mailer_configuration`` service? One way is to use an expression:
644644
# app/config/config.yml
645645
services:
646646
my_mailer:
647-
class: Acme\HelloBundle\Mailer
647+
class: AppBundle\Mailer
648648
arguments: ["@=service('mailer_configuration').getMailerMethod()"]
649649
650650
.. code-block:: xml
@@ -658,7 +658,7 @@ of the new ``mailer_configuration`` service? One way is to use an expression:
658658
>
659659
660660
<services>
661-
<service id="my_mailer" class="Acme\HelloBundle\Mailer">
661+
<service id="my_mailer" class="AppBundle\Mailer">
662662
<argument type="expression">service('mailer_configuration').getMailerMethod()</argument>
663663
</service>
664664
</services>
@@ -671,7 +671,7 @@ of the new ``mailer_configuration`` service? One way is to use an expression:
671671
use Symfony\Component\ExpressionLanguage\Expression;
672672
673673
$container->setDefinition('my_mailer', new Definition(
674-
'Acme\HelloBundle\Mailer',
674+
'AppBundle\Mailer',
675675
array(new Expression('service("mailer_configuration").getMailerMethod()'))
676676
));
677677
@@ -693,7 +693,7 @@ via a ``container`` variable. Here's another example:
693693
694694
services:
695695
my_mailer:
696-
class: Acme\HelloBundle\Mailer
696+
class: AppBundle\Mailer
697697
arguments: ["@=container.hasParameter('some_param') ? parameter('some_param') : 'default_value'"]
698698
699699
.. code-block:: xml
@@ -706,7 +706,7 @@ via a ``container`` variable. Here's another example:
706706
>
707707
708708
<services>
709-
<service id="my_mailer" class="Acme\HelloBundle\Mailer">
709+
<service id="my_mailer" class="AppBundle\Mailer">
710710
<argument type="expression">container.hasParameter('some_param') ? parameter('some_param') : 'default_value'</argument>
711711
</service>
712712
</services>
@@ -718,7 +718,7 @@ via a ``container`` variable. Here's another example:
718718
use Symfony\Component\ExpressionLanguage\Expression;
719719
720720
$container->setDefinition('my_mailer', new Definition(
721-
'Acme\HelloBundle\Mailer',
721+
'AppBundle\Mailer',
722722
array(new Expression(
723723
"container.hasParameter('some_param') ? parameter('some_param') : 'default_value'"
724724
))
@@ -822,7 +822,7 @@ add it as an argument to the methods that need the request or inject the
822822
:method:`Symfony\\Component\\HttpFoundation\\RequestStack::getCurrentRequest`
823823
method::
824824

825-
namespace Acme\HelloBundle\Newsletter;
825+
namespace AppBundle\Newsletter;
826826

827827
use Symfony\Component\HttpFoundation\RequestStack;
828828

@@ -850,15 +850,15 @@ Now, just inject the ``request_stack``, which behaves like any normal service:
850850

851851
.. code-block:: yaml
852852
853-
# src/Acme/HelloBundle/Resources/config/services.yml
853+
# src/AppBundle/Resources/config/services.yml
854854
services:
855855
newsletter_manager:
856-
class: Acme\HelloBundle\Newsletter\NewsletterManager
856+
class: AppBundle\Newsletter\NewsletterManager
857857
arguments: ["@request_stack"]
858858
859859
.. code-block:: xml
860860
861-
<!-- src/Acme/HelloBundle/Resources/config/services.xml -->
861+
<!-- src/AppBundle/Resources/config/services.xml -->
862862
<?xml version="1.0" encoding="UTF-8" ?>
863863
<container xmlns="http://symfony.com/schema/dic/services"
864864
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -867,7 +867,7 @@ Now, just inject the ``request_stack``, which behaves like any normal service:
867867
<services>
868868
<service
869869
id="newsletter_manager"
870-
class="Acme\HelloBundle\Newsletter\NewsletterManager"
870+
class="AppBundle\Newsletter\NewsletterManager"
871871
>
872872
<argument type="service" id="request_stack"/>
873873
</service>
@@ -876,13 +876,13 @@ Now, just inject the ``request_stack``, which behaves like any normal service:
876876
877877
.. code-block:: php
878878
879-
// src/Acme/HelloBundle/Resources/config/services.php
879+
// src/AppBundle/Resources/config/services.php
880880
use Symfony\Component\DependencyInjection\Definition;
881881
use Symfony\Component\DependencyInjection\Reference;
882882
883883
// ...
884884
$container->setDefinition('newsletter_manager', new Definition(
885-
'Acme\HelloBundle\Newsletter\NewsletterManager',
885+
'AppBundle\Newsletter\NewsletterManager',
886886
array(new Reference('request_stack'))
887887
));
888888

components/dependency_injection/autowiring.rst

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ subsystem isn't able to find itself the interface implementation to register:
205205
206206
<services>
207207
<service id="rot13_transformer" class="Acme\Rot13Transformer" />
208+
208209
<service id="twitter_client" class="Acme\TwitterClient" autowire="true" />
209210
</services>
210211
</container>
@@ -214,12 +215,11 @@ subsystem isn't able to find itself the interface implementation to register:
214215
use Symfony\Component\DependencyInjection\Definition;
215216
216217
// ...
217-
$definition1 = new Definition('Acme\Rot13Transformer');
218-
$container->setDefinition('rot13_transformer', $definition1);
218+
$container->register('rot13_transformer', 'Acme\Rot13Transformer');
219219
220-
$definition2 = new Definition('Acme\TwitterClient');
221-
$definition2->setAutowired(true);
222-
$container->setDefinition('twitter_client', $definition2);
220+
$clientDefinition = new Definition('Acme\TwitterClient');
221+
$clientDefinition->setAutowired(true);
222+
$container->setDefinition('twitter_client', $clientDefinition);
223223
224224
The autowiring subsystem detects that the ``rot13_transformer`` service implements
225225
the ``TransformerInterface`` and injects it automatically. Even when using
@@ -252,7 +252,7 @@ returning the result of the ROT13 transformation uppercased::
252252

253253
This class is intended to decorate any transformer and return its value uppercased.
254254

255-
We can now refactor the controller to add another endpoint leveraging this new
255+
The controller can now be refactored to add a new endpoint using this uppercase
256256
transformer::
257257

258258
namespace Acme\Controller;
@@ -316,13 +316,13 @@ and a Twitter client using it:
316316
class: Acme\TwitterClient
317317
autowire: true
318318
319-
uppercase_rot13_transformer:
320-
class: Acme\UppercaseRot13Transformer
319+
uppercase_transformer:
320+
class: Acme\UppercaseTransformer
321321
autowire: true
322322
323323
uppercase_twitter_client:
324324
class: Acme\TwitterClient
325-
arguments: ['@uppercase_rot13_transformer']
325+
arguments: ['@uppercase_transformer']
326326
327327
.. code-block:: xml
328328
@@ -335,10 +335,15 @@ and a Twitter client using it:
335335
<service id="rot13_transformer" class="Acme\Rot13Transformer">
336336
<autowiring-type>Acme\TransformerInterface</autowiring-type>
337337
</service>
338+
338339
<service id="twitter_client" class="Acme\TwitterClient" autowire="true" />
339-
<service id="uppercase_rot13_transformer" class="Acme\UppercaseRot13Transformer" autowire="true" />
340+
341+
<service id="uppercase_transformer" class="Acme\UppercaseTransformer"
342+
autowire="true"
343+
/>
344+
340345
<service id="uppercase_twitter_client" class="Acme\TwitterClient">
341-
<argument type="service" id="uppercase_rot13_transformer" />
346+
<argument type="service" id="uppercase_transformer" />
342347
</service>
343348
</services>
344349
</container>
@@ -349,21 +354,22 @@ and a Twitter client using it:
349354
use Symfony\Component\DependencyInjection\Definition;
350355
351356
// ...
352-
$definition1 = new Definition('Acme\Rot13Transformer');
353-
$definition1->setAutowiringTypes(array('Acme\TransformerInterface'));
354-
$container->setDefinition('rot13_transformer', $definition1);
357+
$rot13Definition = new Definition('Acme\Rot13Transformer');
358+
$rot13Definition->setAutowiringTypes(array('Acme\TransformerInterface'));
359+
$container->setDefinition('rot13_transformer', $rot13Definition);
355360
356-
$definition2 = new Definition('Acme\TwitterClient');
357-
$definition2->setAutowired(true);
358-
$container->setDefinition('twitter_client', $definition2);
361+
$clientDefinition = new Definition('Acme\TwitterClient');
362+
$clientDefinition->setAutowired(true);
363+
$container->setDefinition('twitter_client', $clientDefinition);
359364
360-
$definition3 = new Definition('Acme\UppercaseRot13Transformer');
361-
$definition3->setAutowired(true);
362-
$container->setDefinition('uppercase_rot13_transformer', $definition3);
365+
$uppercaseDefinition = new Definition('Acme\UppercaseTransformer');
366+
$uppercaseDefinition->setAutowired(true);
367+
$container->setDefinition('uppercase_transformer', $uppercaseDefinition);
363368
364-
$definition4 = new Definition('Acme\TwitterClient');
365-
$definition4->addArgument(new Reference('uppercase_rot13_transformer'));
366-
$container->setDefinition('uppercase_twitter_client', $definition4);
369+
$uppercaseClientDefinition = new Definition('Acme\TwitterClient', array(
370+
new Reference('uppercase_transformer'),
371+
));
372+
$container->setDefinition('uppercase_twitter_client', $uppercaseClientDefinition);
367373
368374
This deserves some explanations. You now have two services implementing the
369375
``TransformerInterface``. The autowiring subsystem cannot guess which one
@@ -378,9 +384,9 @@ Fortunately, the ``autowiring_types`` key is here to specify which implementatio
378384
to use by default. This key can take a list of types if necessary.
379385

380386
Thanks to this setting, the ``rot13_transformer`` service is automatically injected
381-
as an argument of the ``uppercase_rot13_transformer`` and ``twitter_client`` services. For
382-
the ``uppercase_twitter_client``, we use a standard service definition to inject
383-
the specific ``uppercase_rot13_transformer`` service.
387+
as an argument of the ``uppercase_transformer`` and ``twitter_client`` services. For
388+
the ``uppercase_twitter_client``, a standard service definition is used to
389+
inject the specific ``uppercase_transformer`` service.
384390

385391
As for other RAD features such as the FrameworkBundle controller or annotations,
386392
keep in mind to not use autowiring in public bundles nor in large projects with

components/options_resolver.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ You can install the component in 2 different ways:
1919

2020
.. include:: /components/require_autoload.rst.inc
2121

22-
Notes on Previous Versions
23-
--------------------------
24-
2522
Usage
2623
-----
2724

contributing/documentation/overview.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ your project:
107107
upstream https://github.com/symfony/symfony-docs.git (fetch)
108108
upstream https://github.com/symfony/symfony-docs.git (push)
109109
110+
Fetch all the commits of the upstream branches by executing this command:
111+
112+
.. code-block:: bash
113+
114+
$ git fetch upstream
115+
110116
The purpose of this step is to allow you work simultaneously on the official
111117
Symfony repository and on your own fork. You'll see this in action in a moment.
112118

@@ -208,6 +214,7 @@ contribution to the Symfony docs:
208214
209215
# create a new branch based on the oldest maintained version
210216
$ cd projects/symfony-docs/
217+
$ git fetch upstream
211218
$ git checkout -b my_changes upstream/2.7
212219
213220
# ... do your changes

0 commit comments

Comments
 (0)