Skip to content

Commit 5f4ab4b

Browse files
committed
Update some examples using 3.3 features
1 parent 2a7f91d commit 5f4ab4b

File tree

6 files changed

+85
-148
lines changed

6 files changed

+85
-148
lines changed

console/commands_as_services.rst

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ with ``console.command``:
2727
2828
# app/config/config.yml
2929
services:
30-
app.command.my_command:
31-
class: AppBundle\Command\MyCommand
32-
tags: [console.command]
30+
AppBundle\Command\MyCommand: [console.command]
3331
3432
.. code-block:: xml
3533
@@ -41,8 +39,7 @@ with ``console.command``:
4139
http://symfony.com/schema/dic/services/services-1.0.xsd">
4240
4341
<services>
44-
<service id="app.command.my_command"
45-
class="AppBundle\Command\MyCommand">
42+
<service id="AppBundle\Command\MyCommand">
4643
<tag name="console.command" />
4744
</service>
4845
</services>
@@ -53,8 +50,7 @@ with ``console.command``:
5350
// app/config/config.php
5451
use AppBundle\Command\MyCommand;
5552
56-
$container
57-
->register('app.command.my_command', MyCommand::class)
53+
$container->register(MyCommand::class)
5854
->addTag('console.command')
5955
;
6056
@@ -131,8 +127,7 @@ inject the ``command.default_name`` parameter:
131127
command.default_name: Javier
132128
133129
services:
134-
app.command.my_command:
135-
class: AppBundle\Command\MyCommand
130+
AppBundle\Command\MyCommand:
136131
arguments: ["%command.default_name%"]
137132
tags: [console.command]
138133
@@ -150,8 +145,7 @@ inject the ``command.default_name`` parameter:
150145
</parameters>
151146
152147
<services>
153-
<service id="app.command.my_command"
154-
class="AppBundle\Command\MyCommand">
148+
<service class="AppBundle\Command\MyCommand">
155149
<argument>%command.default_name%</argument>
156150
<tag name="console.command" />
157151
</service>
@@ -166,7 +160,7 @@ inject the ``command.default_name`` parameter:
166160
$container->setParameter('command.default_name', 'Javier');
167161
168162
$container
169-
->register('app.command.my_command', MyCommand::class)
163+
->register(MyCommand::class)
170164
->setArguments(array('%command.default_name%'))
171165
->addTag('console.command')
172166
;

form/create_form_type_extension.rst

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,18 @@ your class as a service and using the ``form.type_extension`` tag:
8080
8181
.. code-block:: xml
8282
83-
<service id="AppBundle\Form\Extension\ImageTypeExtension">
84-
<tag name="form.type_extension" extended-type="Symfony\Component\Form\Extension\Core\Type\FileType" />
85-
</service>
83+
<!-- app/config/services.xml -->
84+
<?xml version="1.0" encoding="UTF-8" ?>
85+
<container xmlns="http://symfony.com/schema/dic/services"
86+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
87+
xsi:schemaLocation="http://symfony.com/schema/dic/services
88+
http://symfony.com/schema/dic/services/services-1.0.xsd">
89+
90+
<service id="AppBundle\Form\Extension\ImageTypeExtension">
91+
<tag name="form.type_extension" extended-type="Symfony\Component\Form\Extension\Core\Type\FileType" />
92+
</service>
93+
94+
</container>
8695
8796
.. code-block:: php
8897
@@ -106,10 +115,10 @@ type (``FileType``) is built. Let's see an example next.
106115

107116
.. tip::
108117

109-
There is an optional tag attribute called ``priority``, which
110-
defaults to ``0`` and controls the order in which the form
111-
type extensions are loaded (the higher the priority, the earlier
112-
an extension is loaded). This is useful when you need to guarantee
118+
There is an optional tag attribute called ``priority``, which
119+
defaults to ``0`` and controls the order in which the form
120+
type extensions are loaded (the higher the priority, the earlier
121+
an extension is loaded). This is useful when you need to guarantee
113122
that one extension is loaded before or after another extension.
114123

115124
.. versionadded:: 3.2

form/type_guesser.rst

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,24 +188,23 @@ and tag it with ``form.type_guesser``:
188188
services:
189189
# ...
190190
191-
AppBundle\Form\TypeGuesser\PHPDocTypeGuesser:
192-
tags: [form.type_guesser]
191+
AppBundle\Form\TypeGuesser\PHPDocTypeGuesser: [form.type_guesser]
193192
194193
.. code-block:: xml
195194
196195
<!-- app/config/services.xml -->
197196
<?xml version="1.0" encoding="UTF-8" ?>
198197
<container xmlns="http://symfony.com/schema/dic/services"
199-
xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance"
200-
xsd:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"
201-
>
202-
<services>
198+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
199+
xsi:schemaLocation="http://symfony.com/schema/dic/services
200+
http://symfony.com/schema/dic/services/services-1.0.xsd">
203201
202+
<services>
204203
<service id="AppBundle\Form\TypeGuesser\PHPDocTypeGuesser">
205204
<tag name="form.type_guesser"/>
206205
</service>
207-
208206
</services>
207+
209208
</container>
210209
211210
.. code-block:: php

0 commit comments

Comments
 (0)