Skip to content

Commit 9e6314d

Browse files
committed
Merge branch '2.2' into 2.3
Conflicts: components/locale.rst
2 parents 4557fee + acc1de0 commit 9e6314d

File tree

24 files changed

+304
-126
lines changed

24 files changed

+304
-126
lines changed

book/forms.rst

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,72 @@ the choice is ultimately up to you.
10591059

10601060
$form->get('dueDate')->getData();
10611061

1062+
Defining your Forms as Services
1063+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1064+
1065+
Defining your form type as a service is a good practice and makes it really
1066+
easy to use in your application.
1067+
1068+
.. configuration-block::
1069+
1070+
.. code-block:: yaml
1071+
1072+
# src/Acme/TaskBundle/Resources/config/services.yml
1073+
services:
1074+
acme_demo.form.type.task:
1075+
class: Acme\TaskBundle\Form\Type\TaskType
1076+
tags:
1077+
- { name: form.type, alias: task }
1078+
1079+
.. code-block:: xml
1080+
1081+
<!-- src/Acme/TaskBundle/Resources/config/services.xml -->
1082+
<service id="acme_demo.form.type.task" class="Acme\TaskBundle\Form\Type\TaskType">
1083+
<tag name="form.type" alias="task" />
1084+
</service>
1085+
1086+
.. code-block:: php
1087+
1088+
// src/Acme/TaskBundle/Resources/config/services.php
1089+
use Symfony\Component\DependencyInjection\Definition;
1090+
1091+
$container
1092+
->register('acme_demo.form.type.task', 'Acme\TaskBundle\Form\Type\TaskType')
1093+
->addTag('form.type', array(
1094+
'alias' => 'task',
1095+
))
1096+
;
1097+
1098+
That's it! Now you can use your form type directly in a controller::
1099+
1100+
// src/Acme/TaskBundle/Controller/DefaultController.php
1101+
// ...
1102+
1103+
public function newAction()
1104+
{
1105+
$task = ...;
1106+
$form = $this->createForm('task', $task);
1107+
1108+
// ...
1109+
}
1110+
1111+
or even use from within the form type of another form::
1112+
1113+
// src/Acme/TaskBundle/Form/Type/ListType.php
1114+
// ...
1115+
1116+
class ListType extends AbstractType
1117+
{
1118+
public function buildForm(FormBuilderInterface $builder, array $options)
1119+
{
1120+
// ...
1121+
1122+
$builder->add('someTask', 'task');
1123+
}
1124+
}
1125+
1126+
Read :ref:`form-cookbook-form-field-service` for more information.
1127+
10621128
.. index::
10631129
pair: Forms; Doctrine
10641130

book/installation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ you'll start to develop your own application. A Symfony project depends on
149149
a number of external libraries. These are downloaded into the `vendor/` directory
150150
of your project via a library called `Composer`_.
151151

152-
Depending on how you downloaded Symfony, you may or may not need to do update
152+
Depending on how you downloaded Symfony, you may or may not need to update
153153
your vendors right now. But, updating your vendors is always safe, and guarantees
154154
that you have all the vendor libraries you need.
155155

components/class_loader.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ need.
2525
Installation
2626
------------
2727

28-
You can install the component in many different ways:
28+
You can install the component in 2 different ways:
2929

3030
* Use the official Git repository (https://github.com/symfony/ClassLoader);
31-
* :doc:`Install it via Composer</components/using_components>` (``symfony/class-loader`` on `Packagist`_).
31+
* :doc:`Install it via Composer </components/using_components>` (``symfony/class-loader`` on `Packagist`_).
3232

3333
Usage
3434
-----

components/config/introduction.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ may be (Yaml, XML, INI files, or for instance a database).
1515
Installation
1616
------------
1717

18-
You can install the component in many different ways:
18+
You can install the component in 2 different ways:
1919

2020
* Use the official Git repository (https://github.com/symfony/Config);
21-
* :doc:`Install it via Composer</components/using_components>` (``symfony/config`` on `Packagist`_).
21+
* :doc:`Install it via Composer </components/using_components>` (``symfony/config`` on `Packagist`_).
2222

2323
Sections
2424
--------
@@ -27,4 +27,4 @@ Sections
2727
* :doc:`/components/config/caching`
2828
* :doc:`/components/config/definition`
2929

30-
.. _Packagist: https://packagist.org/packages/symfony/config
30+
.. _Packagist: https://packagist.org/packages/symfony/config

components/console/introduction.rst

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ other batch jobs.
1515
Installation
1616
------------
1717

18-
You can install the component in many different ways:
18+
You can install the component in 2 different ways:
1919

2020
* Use the official Git repository (https://github.com/symfony/Console);
21-
* :doc:`Install it via Composer</components/using_components>` (``symfony/console`` on `Packagist`_).
21+
* :doc:`Install it via Composer </components/using_components>` (``symfony/console`` on `Packagist`_).
2222

2323
.. note::
2424

@@ -235,6 +235,50 @@ The command can now be used in either of the following ways:
235235
$ app/console demo:greet Fabien
236236
$ app/console demo:greet Fabien Potencier
237237
238+
It is also possible to let an argument take a list of values (imagine you want
239+
to greet all your friends). For this it must be specified at the end of the
240+
argument list::
241+
242+
$this
243+
// ...
244+
->addArgument(
245+
'names',
246+
InputArgument::IS_ARRAY,
247+
'Who do you want to greet (separate multiple names with a space)?'
248+
);
249+
250+
To use this, just specify as many names as you want:
251+
252+
.. code-block:: bash
253+
254+
$ app/console demo:greet Fabien Ryan Bernhard
255+
256+
You can access the ``names`` argument as an array::
257+
258+
if ($names = $input->getArgument('names')) {
259+
$text .= ' '.implode(', ', $names);
260+
}
261+
262+
There are 3 argument variants you can use:
263+
264+
=========================== ===============================================================================================================
265+
Option Value
266+
=========================== ===============================================================================================================
267+
InputArgument::REQUIRED The argument is required
268+
InputArgument::OPTIONAL The argument is optional and therefore can be omitted
269+
InputArgument::IS_ARRAY The argument can can contain an indefinite number of arguments and must be used at the end of the argument list
270+
=========================== ===============================================================================================================
271+
272+
You can combine ``IS_ARRAY`` with ``REQUIRED`` and ``OPTIONAL`` like this::
273+
274+
$this
275+
// ...
276+
->addArgument(
277+
'names',
278+
InputArgument::IS_ARRAY | InputArgument::REQUIRED,
279+
'Who do you want to greet (separate multiple names with a space)?'
280+
);
281+
238282
Using Command Options
239283
---------------------
240284

@@ -303,7 +347,7 @@ InputOption::VALUE_REQUIRED This value is required (e.g. ``--iterations=5``), t
303347
InputOption::VALUE_OPTIONAL This option may or may not have a value (e.g. ``yell`` or ``yell=loud``)
304348
=========================== =====================================================================================
305349

306-
You can combine VALUE_IS_ARRAY with VALUE_REQUIRED or VALUE_OPTIONAL like this:
350+
You can combine ``VALUE_IS_ARRAY`` with ``VALUE_REQUIRED`` or ``VALUE_OPTIONAL`` like this:
307351

308352
.. code-block:: php
309353

components/css_selector.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ The CssSelector Component
1010
Installation
1111
------------
1212

13-
You can install the component in several different ways:
13+
You can install the component in 2 different ways:
1414

1515
* Use the official Git repository (https://github.com/symfony/CssSelector);
16-
* :doc:`Install it via Composer</components/using_components>` (``symfony/css-selector`` on `Packagist`_).
16+
* :doc:`Install it via Composer </components/using_components>` (``symfony/css-selector`` on `Packagist`_).
1717

1818
Usage
1919
-----
@@ -91,4 +91,4 @@ Several pseudo-classes are not yet supported:
9191
``*:nth-last-of-type``, ``*:only-of-type``. (These work with an element
9292
name (e.g. ``li:first-of-type``) but not with ``*``.
9393

94-
.. _Packagist: https://packagist.org/packages/symfony/css-selector
94+
.. _Packagist: https://packagist.org/packages/symfony/css-selector

components/dependency_injection/introduction.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ For an introduction to Dependency Injection and service containers see
1414
Installation
1515
------------
1616

17-
You can install the component in many different ways:
17+
You can install the component in 2 different ways:
1818

1919
* Use the official Git repository (https://github.com/symfony/DependencyInjection);
20-
* :doc:`Install it via Composer</components/using_components>` (``symfony/dependency-injection`` on `Packagist`_).
20+
* :doc:`Install it via Composer </components/using_components>` (``symfony/dependency-injection`` on `Packagist`_).
2121

2222
Basic Usage
2323
-----------

components/dom_crawler.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ The DomCrawler Component
1515
Installation
1616
------------
1717

18-
You can install the component in many different ways:
18+
You can install the component in 2 different ways:
1919

2020
* Use the official Git repository (https://github.com/symfony/DomCrawler);
21-
* :doc:`Install it via Composer</components/using_components>` (``symfony/dom-crawler`` on `Packagist`_).
21+
* :doc:`Install it via Composer </components/using_components>` (``symfony/dom-crawler`` on `Packagist`_).
2222

2323
Usage
2424
-----

components/event_dispatcher/introduction.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ used. To make this possible, the Symfony2 kernel throws an event -
4747
Installation
4848
------------
4949

50-
You can install the component in many different ways:
50+
You can install the component in 2 different ways:
5151

5252
* Use the official Git repository (https://github.com/symfony/EventDispatcher);
53-
* :doc:`Install it via Composer</components/using_components>` (``symfony/event-dispatcher`` on `Packagist`_).
53+
* :doc:`Install it via Composer </components/using_components>` (``symfony/event-dispatcher`` on `Packagist`_).
5454

5555
Usage
5656
-----

components/filesystem.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ The Filesystem Component
99
Installation
1010
------------
1111

12-
You can install the component in many different ways:
12+
You can install the component in 2 different ways:
1313

1414
* Use the official Git repository (https://github.com/symfony/Filesystem);
15-
* Install it via Composer (``symfony/filesystem`` on `Packagist`_).
15+
* :doc:`Install it via Composer </components/using_components>` (``symfony/filesystem`` on `Packagist`_).
1616

1717
Usage
1818
-----

components/finder.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ The Finder Component
1111
Installation
1212
------------
1313

14-
You can install the component in many different ways:
14+
You can install the component in 2 different ways:
1515

1616
* Use the official Git repository (https://github.com/symfony/Finder);
17-
* :doc:`Install it via Composer</components/using_components>` (``symfony/finder`` on `Packagist`_).
17+
* :doc:`Install it via Composer </components/using_components>` (``symfony/finder`` on `Packagist`_).
1818

1919
Usage
2020
-----

components/http_foundation/introduction.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ variables and functions by an Object-Oriented layer.
1919
Installation
2020
------------
2121

22-
You can install the component in many different ways:
22+
You can install the component in 2 different ways:
2323

2424
* Use the official Git repository (https://github.com/symfony/HttpFoundation);
25-
* :doc:`Install it via Composer</components/using_components>` (``symfony/http-foundation`` on `Packagist`_).
25+
* :doc:`Install it via Composer </components/using_components>` (``symfony/http-foundation`` on `Packagist`_).
2626

2727
Request
2828
-------

components/http_kernel/introduction.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ The HttpKernel Component
1414
Installation
1515
------------
1616

17-
You can install the component in many different ways:
17+
You can install the component in 2 different ways:
1818

1919
* Use the official Git repository (https://github.com/symfony/HttpKernel);
20-
* :doc:`Install it via Composer</components/using_components>` (``symfony/http-kernel`` on Packagist_).
20+
* :doc:`Install it via Composer </components/using_components>` (``symfony/http-kernel`` on Packagist_).
2121

2222
The Workflow of a Request
2323
-------------------------
@@ -230,7 +230,7 @@ will be called after another event - ``kernel.controller`` - is dispatched.
230230

231231
The Symfony Framework uses the built-in
232232
:class:`Symfony\\Component\\HttpKernel\\Controller\\ControllerResolver`
233-
class (actually, it uses a sub-class, which some extra functionality
233+
class (actually, it uses a sub-class with some extra functionality
234234
mentioned below). This class leverages the information that was placed
235235
on the ``Request`` object's ``attributes`` property during the ``RouterListener``.
236236

components/options_resolver.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ The OptionsResolver Component
1111
Installation
1212
------------
1313

14-
You can install the component in several different ways:
14+
You can install the component in 2 different ways:
1515

1616
* Use the official Git repository (https://github.com/symfony/OptionsResolver
17-
* :doc:`Install it via Composer</components/using_components>` (``symfony/options-resolver`` on `Packagist`_)
17+
* :doc:`Install it via Composer </components/using_components>` (``symfony/options-resolver`` on `Packagist`_)
1818

1919
Usage
2020
-----

components/process.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ The Process Component
1010
Installation
1111
------------
1212

13-
You can install the component in many different ways:
13+
You can install the component in 2 different ways:
1414

1515
* Use the official Git repository (https://github.com/symfony/Process);
16-
* :doc:`Install it via Composer</components/using_components>` (``symfony/process`` on `Packagist`_).
16+
* :doc:`Install it via Composer </components/using_components>` (``symfony/process`` on `Packagist`_).
1717

1818
Usage
1919
-----

components/routing/introduction.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ The Routing Component
1111
Installation
1212
------------
1313

14-
You can install the component in many different ways:
14+
You can install the component in 2 different ways:
1515

1616
* Use the official Git repository (https://github.com/symfony/Routing);
17-
* :doc:`Install it via Composer</components/using_components>` (``symfony/routing`` on `Packagist`_).
17+
* :doc:`Install it via Composer </components/using_components>` (``symfony/routing`` on `Packagist`_).
1818

1919
Usage
2020
-----

components/security/introduction.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ based on their roles, and it contains an advanced ACL system.
1717
Installation
1818
------------
1919

20-
You can install the component in many different ways:
20+
You can install the component in 2 different ways:
2121

2222
* Use the official Git repository (https://github.com/symfony/Security);
23-
* :doc:`Install it via Composer</components/using_components>` (``symfony/security`` on Packagist_).
23+
* :doc:`Install it via Composer </components/using_components>` (``symfony/security`` on Packagist_).
2424

2525
Sections
2626
--------
@@ -29,4 +29,4 @@ Sections
2929
* :doc:`/components/security/authentication`
3030
* :doc:`/components/security/authorization`
3131

32-
.. _Packagist: https://packagist.org/packages/symfony/security
32+
.. _Packagist: https://packagist.org/packages/symfony/security

components/serializer.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ and deserialize your objects.
2828
Installation
2929
------------
3030

31-
You can install the component in many different ways:
31+
You can install the component in 2 different ways:
3232

3333
* Use the official Git repository (https://github.com/symfony/Serializer);
34-
* :doc:`Install it via Composer</components/using_components>` (``symfony/serializer`` on `Packagist`_).
34+
* :doc:`Install it via Composer </components/using_components>` (``symfony/serializer`` on `Packagist`_).
3535

3636
Usage
3737
-----

components/templating.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ The Templating Component
1616
Installation
1717
------------
1818

19-
You can install the component in many different ways:
19+
You can install the component in 2 different ways:
2020

2121
* Use the official Git repository (https://github.com/symfony/Templating);
22-
* :doc:`Install it via Composer</components/using_components>` (``symfony/templating`` on `Packagist`_).
22+
* :doc:`Install it via Composer </components/using_components>` (``symfony/templating`` on `Packagist`_).
2323

2424
Usage
2525
-----
@@ -110,4 +110,4 @@ The Asset Helper
110110

111111
This documentation is still being written.
112112

113-
.. _Packagist: https://packagist.org/packages/symfony/templating
113+
.. _Packagist: https://packagist.org/packages/symfony/templating

0 commit comments

Comments
 (0)