Skip to content

Commit acc1de0

Browse files
committed
Merge branch '2.1' into 2.2
2 parents 954a9ef + 1a1e753 commit acc1de0

25 files changed

+306
-128
lines changed

book/forms.rst

+66
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,72 @@ the choice is ultimately up to you.
883883

884884
$form->get('dueDate')->getData();
885885

886+
Defining your Forms as Services
887+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
888+
889+
Defining your form type as a service is a good practice and makes it really
890+
easy to use in your application.
891+
892+
.. configuration-block::
893+
894+
.. code-block:: yaml
895+
896+
# src/Acme/TaskBundle/Resources/config/services.yml
897+
services:
898+
acme_demo.form.type.task:
899+
class: Acme\TaskBundle\Form\Type\TaskType
900+
tags:
901+
- { name: form.type, alias: task }
902+
903+
.. code-block:: xml
904+
905+
<!-- src/Acme/TaskBundle/Resources/config/services.xml -->
906+
<service id="acme_demo.form.type.task" class="Acme\TaskBundle\Form\Type\TaskType">
907+
<tag name="form.type" alias="task" />
908+
</service>
909+
910+
.. code-block:: php
911+
912+
// src/Acme/TaskBundle/Resources/config/services.php
913+
use Symfony\Component\DependencyInjection\Definition;
914+
915+
$container
916+
->register('acme_demo.form.type.task', 'Acme\TaskBundle\Form\Type\TaskType')
917+
->addTag('form.type', array(
918+
'alias' => 'task',
919+
))
920+
;
921+
922+
That's it! Now you can use your form type directly in a controller::
923+
924+
// src/Acme/TaskBundle/Controller/DefaultController.php
925+
// ...
926+
927+
public function newAction()
928+
{
929+
$task = ...;
930+
$form = $this->createForm('task', $task);
931+
932+
// ...
933+
}
934+
935+
or even use from within the form type of another form::
936+
937+
// src/Acme/TaskBundle/Form/Type/ListType.php
938+
// ...
939+
940+
class ListType extends AbstractType
941+
{
942+
public function buildForm(FormBuilderInterface $builder, array $options)
943+
{
944+
// ...
945+
946+
$builder->add('someTask', 'task');
947+
}
948+
}
949+
950+
Read :ref:`form-cookbook-form-field-service` for more information.
951+
886952
.. index::
887953
pair: Forms; Doctrine
888954

book/installation.rst

+1-1
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

+2-2
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

+3-3
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

+47-3
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

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

@@ -297,7 +341,7 @@ InputOption::VALUE_REQUIRED This value is required (e.g. ``--iterations=5``), t
297341
InputOption::VALUE_OPTIONAL This option may or may not have a value (e.g. ``yell`` or ``yell=loud``)
298342
=========================== =====================================================================================
299343

300-
You can combine VALUE_IS_ARRAY with VALUE_REQUIRED or VALUE_OPTIONAL like this:
344+
You can combine ``VALUE_IS_ARRAY`` with ``VALUE_REQUIRED`` or ``VALUE_OPTIONAL`` like this:
301345

302346
.. code-block:: php
303347

components/css_selector.rst

+3-3
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

+2-2
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

+2-2
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

+2-2
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

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ The Filesystem Component
1313
Installation
1414
------------
1515

16-
You can install the component in many different ways:
16+
You can install the component in 2 different ways:
1717

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

2121
Usage
2222
-----

components/finder.rst

+2-2
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

+2-2
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

+3-3
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/locale.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ Replacement for the following functions and classes is provided:
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/Locale);
31-
* :doc:`Install it via Composer</components/using_components>` (``symfony/locale`` on `Packagist`_).
31+
* :doc:`Install it via Composer </components/using_components>` (``symfony/locale`` on `Packagist`_).
3232

3333
Usage
3434
-----

components/options_resolver.rst

+2-2
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

+2-2
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

+2-2
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

+3-3
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

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ and deserialize your objects.
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/Serializer);
31-
* :doc:`Install it via Composer</components/using_components>` (``symfony/serializer`` on `Packagist`_).
31+
* :doc:`Install it via Composer </components/using_components>` (``symfony/serializer`` on `Packagist`_).
3232

3333
Usage
3434
-----

0 commit comments

Comments
 (0)