Skip to content

Commit 71de41a

Browse files
committed
Merge branch '2.1' into 2.2
2 parents 4140805 + 0d62bfc commit 71de41a

30 files changed

+387
-48
lines changed

book/propel.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ you:
6868

6969
In this example, you have one configured connection, named ``default``. If
7070
you want to configure more than one connection, read the `PropelBundle
71-
configuration section <Working With Symfony2 - Configuration>`_.
71+
configuration section`_.
7272

7373
Creating a Model Class
7474
~~~~~~~~~~~~~~~~~~~~~~
@@ -434,7 +434,7 @@ Commands
434434
You should read the dedicated section for `Propel commands in Symfony2`_.
435435

436436
.. _`Working With Symfony2`: http://propelorm.org/cookbook/symfony2/working-with-symfony2.html#installation
437-
.. _`Working With Symfony2 - Configuration`: http://propelorm.org/cookbook/symfony2/working-with-symfony2.html#configuration
437+
.. _`PropelBundle configuration section`: http://propelorm.org/cookbook/symfony2/working-with-symfony2.html#configuration
438438
.. _`Relationships`: http://propelorm.org/documentation/04-relationships.html
439439
.. _`Behaviors reference section`: http://propelorm.org/documentation/#behaviors_reference
440440
.. _`Propel commands in Symfony2`: http://propelorm.org/cookbook/symfony2/working-with-symfony2#the_commands

book/testing.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,16 @@ or perform more complex requests::
345345
// Directly submit a form (but using the Crawler is easier!)
346346
$client->request('POST', '/submit', array('name' => 'Fabien'));
347347

348+
// Submit a raw JSON string in the requst body
349+
$client->request(
350+
'POST',
351+
'/submit',
352+
array(),
353+
array(),
354+
array('CONTENT_TYPE' => 'application/json'),
355+
'{"name":"Fabien"}'
356+
);
357+
348358
// Form submission with a file upload
349359
use Symfony\Component\HttpFoundation\File\UploadedFile;
350360

components/console/introduction.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,39 @@ You can also set these colors and options inside the tagname::
160160
// bold text on a yellow background
161161
$output->writeln('<bg=yellow;options=bold>foo</bg=yellow;options=bold>');
162162

163+
Verbosity Levels
164+
~~~~~~~~~~~~~~~~
165+
166+
The console has 3 levels of verbosity. These are defined in the
167+
:class:`Symfony\\Component\\Console\\Output\\OutputInterface`:
168+
169+
================================== ===============================
170+
Option Value
171+
================================== ===============================
172+
OutputInterface::VERBOSITY_QUIET Do not output any messages
173+
OutputInterface::VERBOSITY_NORMAL The default verbosity level
174+
OutputInterface::VERBOSITY_VERBOSE Increased verbosity of messages
175+
================================== ===============================
176+
177+
You can specify the quiet verbosity level with the ``--quiet`` or ``-q``
178+
option. The ``--verbose`` or ``-v`` option is used when you want an increased
179+
level of verbosity.
180+
181+
.. tip::
182+
183+
The full exception stacktrace is printed if the ``VERBOSITY_VERBOSE``
184+
level is used.
185+
186+
It is possible to print a message in a command for only a specific verbosity
187+
level. For example::
188+
189+
if (OutputInterface::VERBOSITY_VERBOSE === $output->getVerbosity()) {
190+
$output->writeln(...);
191+
}
192+
193+
When the quiet level is used, all output is suppressed as the default
194+
:method:`Symfony\Component\Console\Output::write<Symfony\\Component\\Console\\Output::write>`
195+
method returns without actually printing.
163196

164197
Using Command Arguments
165198
-----------------------

components/dependency_injection/compilation.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,10 @@ something needed in everyday use.
316316
The compiler pass must have the ``process`` method which is passed the container
317317
being compiled::
318318

319-
class CustomCompilerPass
319+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
320+
use Symfony\Component\DependencyInjection\ContainerBuilder;
321+
322+
class CustomCompilerPass implements CompilerPassInterface
320323
{
321324
public function process(ContainerBuilder $container)
322325
{

components/dom_crawler.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,16 +278,16 @@ To work with multi-dimensional fields::
278278
<input name="multi[dimensional]" />
279279
</form>
280280

281-
You must specify the fully qualified name of the field::
281+
Pass an array of values::
282282

283283
// Set a single field
284-
$form->setValue('multi[0]', 'value');
284+
$form->setValues(array('multi' => array('value')));
285285

286286
// Set multiple fields at once
287-
$form->setValue('multi', array(
287+
$form->setValues(array('multi' => array(
288288
1 => 'value',
289289
'dimensional' => 'an other value'
290-
));
290+
)));
291291

292292
This is great, but it gets better! The ``Form`` object allows you to interact
293293
with your form like a browser, selecting radio values, ticking checkboxes,

components/serializer.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ use the Serializer service created before::
9090
$person->setName('foo');
9191
$person->setAge(99);
9292

93-
$serializer->serialize($person, 'json'); // Output: {"name":"foo","age":99}
93+
$jsonContent = $serializer->serialize($person, 'json');
94+
95+
// $jsonContent contains {"name":"foo","age":99}
96+
97+
echo $jsonContent; // or return it in a Response
9498

9599
The first parameter of the :method:`Symfony\\Component\\Serializer\\Serializer::serialize`
96100
is the object to be serialized and the second is used to choose the proper encoder,

cookbook/bundles/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Bundles
44
.. toctree::
55
:maxdepth: 2
66

7+
installation
78
best_practices
89
inheritance
910
override

cookbook/bundles/installation.rst

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
.. index::
2+
single: Bundle; Installation
3+
4+
How to install 3rd party Bundles
5+
================================
6+
7+
Most bundles provide their own installation instructions. However, the
8+
basic steps for installing a bundle are the same.
9+
10+
Add Composer Dependencies
11+
-------------------------
12+
13+
Starting from Symfony 2.1, dependencies are managed with Composer. It's
14+
a good idea to learn some basics of Composer in `their documentation`_.
15+
16+
Before you can use composer to install a bundle, you should look for a
17+
`Packagist`_ package of that bundle. For example, if you search for the popular
18+
`FOSUserBundle`_ you will find a packaged called `friendsofsymfony/user-bundle`_.
19+
20+
.. note::
21+
22+
Packagist is the main archive for Composer. If you are searching
23+
for a bundle, the best thing you can do is check out
24+
`KnpBundles`_, it is the unofficial achive of Symfony Bundles. If
25+
a bundle contains a ``README`` file, it is displayed there and if it
26+
has a Packagist package it shows a link to the package. It's a
27+
really useful site to begin searching for bundles.
28+
29+
Now that you have the package name, you should determine the version
30+
you want to use. Usually different versions of a bundle correspond to
31+
a particular version of Symfony. This information should be in the ``README``
32+
file. If it isn't, you can use the version you want. If you choose an incompatible
33+
version, Composer will throw dependency errors when you try to install. If
34+
this happens, you can try a different version.
35+
36+
In the case of the FOSUserBundle, the ``README`` file has a caution that version
37+
1.2.0 must be used for Symfony 2.0 and 1.3+ for Symfony 2.1+. Packagist displays
38+
example ``require`` statements for all existing versions of a package. The
39+
current development version of FOSUserBundle is ``"friendsofsymfony/user-bundle": "2.0.*@dev"``.
40+
41+
Now you can add the bundle to your ``composer.json`` file and update the
42+
dependencies. You can do this manually:
43+
44+
1. **Add it to the composer.json file:**
45+
46+
.. code-block:: json
47+
48+
{
49+
...,
50+
"require": {
51+
...,
52+
"friendsofsymfony/user-bundle": "2.0.*@dev"
53+
}
54+
}
55+
56+
2. **Update the dependency:**
57+
58+
.. code-block:: bash
59+
60+
$ php composer.phar update friendsofsymfony/user-bundle
61+
62+
or update all dependencies
63+
64+
.. code-block:: bash
65+
66+
$ php composer.phar update
67+
68+
Or you can do this in one command:
69+
70+
.. code-block:: bash
71+
72+
$ php composer.phar require friendsofsymfony/user-bundle:2.0.*@dev
73+
74+
Enable the Bundle
75+
-----------------
76+
77+
At this point, the bundle is installed in your Symfony project (in
78+
``vendor/friendsofsymfony/``) and the autoloader recognizes its classes.
79+
The only thing you need to do now is register the bundle in ``AppKernel``::
80+
81+
// app/AppKernel.php
82+
83+
// ...
84+
class AppKernel extends Kernel
85+
{
86+
// ...
87+
88+
public function registerBundles()
89+
{
90+
$bundles = array(
91+
// ...,
92+
new FOS\UserBundle\FOSUserBundle(),
93+
);
94+
95+
// ...
96+
}
97+
}
98+
99+
Configure the Bundle
100+
--------------------
101+
102+
Usually a bundle requires some configuration to be added to app's
103+
``app/config/config.yml`` file. The bundle's documentation will likely
104+
describe that configuration. But you can also get a reference of the
105+
bundle's config via the ``config:dump-reference`` command.
106+
107+
For instance, in order to look the reference of the ``assetic`` config you
108+
can use this:
109+
110+
.. code-block:: bash
111+
112+
$ app/console config:dump-reference AsseticBundle
113+
114+
or this:
115+
116+
.. code-block:: bash
117+
118+
$ app/console config:dump-reference assetic
119+
120+
The output will look like this:
121+
122+
.. code-block:: text
123+
124+
assetic:
125+
debug: %kernel.debug%
126+
use_controller:
127+
enabled: %kernel.debug%
128+
profiler: false
129+
read_from: %kernel.root_dir%/../web
130+
write_to: %assetic.read_from%
131+
java: /usr/bin/java
132+
node: /usr/local/bin/node
133+
node_paths: []
134+
# ...
135+
136+
Other Setup
137+
-----------
138+
139+
At this point, check the ``README`` file of your brand new bundle to see
140+
what do to next.
141+
142+
.. _their documentation: http://getcomposer.org/doc/00-intro.md
143+
.. _Packagist: https://packagist.org
144+
.. _FOSUserBundle: https://github.com/FriendsOfSymfony/FOSUserBundle
145+
.. _`friendsofsymfony/user-bundle`: https://packagist.org/packages/friendsofsymfony/user-bundle
146+
.. _KnpBundles: http://knpbundles.com/

cookbook/controller/error_pages.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ end-user, create a new template located at
5656
by your error pages), because the router runs before the firewall. If
5757
the router throws an exception (for instance, when the route does not
5858
match), then using ``is_granted`` will throw a further exception. You
59-
can use ``is_granted`` safely by saying ``{% if app.security and is_granted('...') %}``.
59+
can use ``is_granted`` safely by saying ``{% if app.user and is_granted('...') %}``.
6060

6161
.. tip::
6262

cookbook/doctrine/file_uploads.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
.. index::
22
single: Doctrine; File uploads
33

4-
54
How to handle File Uploads with Doctrine
65
========================================
76

@@ -120,7 +119,7 @@ look like this::
120119
Next, create this property on your ``Document`` class and add some validation
121120
rules::
122121

123-
use Symfony\Component\HttpFoundation\File\UploadedFile;
122+
use Symfony\Component\HttpFoundation\File\UploadedFile;
124123

125124
// ...
126125
class Document

cookbook/form/dynamic_form_modification.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,11 @@ How to Dynamically Generate Forms based on user data
155155
====================================================
156156

157157
Sometimes you want a form to be generated dynamically based not only on data
158-
from this form (see :doc:`Dynamic form generation</cookbook/dynamic_form_generation>`)
159-
but also on something else. For example depending on the user currently using
160-
the application. If you have a social website where a user can only message
161-
people who are his friends on the website, then the current user doesn't need to
162-
be included as a field of your form, but a "choice list" of whom to message
163-
should only contain users that are the current user's friends.
158+
from this form but also on something else. For example depending on the user
159+
currently using the application. If you have a social website where a user can
160+
only message people who are his friends on the website, then the current user
161+
doesn't need to be included as a field of your form, but a "choice list" of
162+
whom to message should only contain users that are the current user's friends.
164163

165164
Creating the form type
166165
----------------------

cookbook/form/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ Form
1212
create_form_type_extension
1313
use_virtuals_forms
1414
unit_testing
15+
use_empty_data

cookbook/form/unit_testing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ Adding custom Extensions
149149
------------------------
150150

151151
It often happens that you use some options that are added by
152-
:doc:`form extensions<cookbook/form/create_form_type_extension>`. One of the
152+
:doc:`form extensions</cookbook/form/create_form_type_extension>`. One of the
153153
cases may be the ``ValidatorExtension`` with its ``invalid_message`` option.
154154
The ``TypeTestCase`` loads only the core form extension so an "Invalid option"
155155
exception will be raised if you try to use it for testing a class that depends

0 commit comments

Comments
 (0)