Skip to content

Commit 07c649f

Browse files
committed
Merge branch '2.1' into 2.2
Conflicts: book/http_cache.rst book/templating.rst
2 parents 728dec8 + cf6cbaf commit 07c649f

30 files changed

+724
-98
lines changed

book/controller.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ a controller object. Controllers are also called *actions*.
102102
{
103103
public function indexAction($name)
104104
{
105-
return new Response('<html><body>Hello '.$name.'!</body></html>');
105+
return new Response('<html><body>Hello '.$name.'!</body></html>');
106106
}
107107
}
108108
@@ -684,7 +684,7 @@ the ``notice`` message:
684684
</div>
685685
{% endfor %}
686686

687-
.. code-block:: php
687+
.. code-block:: html+php
688688

689689
<?php foreach ($view['session']->getFlash('notice') as $message): ?>
690690
<div class="flash-notice">

book/http_cache.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ First, to use ESI, be sure to enable it in your application configuration:
854854
855855
// app/config/config.php
856856
$container->loadFromExtension('framework', array(
857-
...,
857+
// ...
858858
'esi' => array('enabled' => true),
859859
));
860860
@@ -891,7 +891,7 @@ matter), Symfony2 uses the standard ``render`` helper to configure ESI tags:
891891
{# ... or a URL #}
892892
{{ render_esi(url('latest_news', { 'max': 5 })) }}
893893
894-
.. code-block:: php
894+
.. code-block:: html+php
895895

896896
<?php echo $view['actions']->render(
897897
new ControllerReference('...:news', array('max' => 5)),

book/installation.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,10 @@ Distribution:
6666

6767
.. tip::
6868

69-
To download the vendor files faster and without unnecessary directories
70-
(e.g. "Tests"), add the ``--prefer-dist`` option at the end of any Composer
71-
command.
69+
To download the vendor files faster, add the ``--prefer-dist`` option at
70+
the end of any Composer command.
7271

73-
This command may take several minutes to run as Composer download the Standard
72+
This command may take several minutes to run as Composer downloads the Standard
7473
Distribution along with all of the vendor libraries that it needs. When it finishes,
7574
you should have a directory that looks something like this:
7675

book/page_creation.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ controller, and ``index.html.twig`` the template:
344344
Hello {{ name }}!
345345
{% endblock %}
346346
347-
.. code-block:: php
347+
.. code-block:: html+php
348348

349349
<!-- src/Acme/HelloBundle/Resources/views/Hello/index.html.php -->
350350
<?php $view->extend('::base.html.php') ?>
@@ -385,7 +385,7 @@ and in the ``app`` directory:
385385
</body>
386386
</html>
387387

388-
.. code-block:: php
388+
.. code-block:: html+php
389389

390390
<!-- app/Resources/views/base.html.php -->
391391
<!DOCTYPE html>

book/routing.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,7 +1207,7 @@ a template helper function:
12071207
Read this blog post.
12081208
</a>
12091209

1210-
.. code-block:: php
1210+
.. code-block:: html+php
12111211

12121212
<a href="<?php echo $view['router']->generate('blog_show', array('slug' => 'my-blog-post')) ?>">
12131213
Read this blog post.
@@ -1223,7 +1223,7 @@ Absolute URLs can also be generated.
12231223
Read this blog post.
12241224
</a>
12251225

1226-
.. code-block:: php
1226+
.. code-block:: html+php
12271227

12281228
<a href="<?php echo $view['router']->generate('blog_show', array('slug' => 'my-blog-post'), true) ?>">
12291229
Read this blog post.

book/security.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ Finally, create the corresponding template:
493493

494494
.. code-block:: html+php
495495

496-
<?php // src/Acme/SecurityBundle/Resources/views/Security/login.html.php ?>
496+
<!-- src/Acme/SecurityBundle/Resources/views/Security/login.html.php -->
497497
<?php if ($error): ?>
498498
<div><?php echo $error->getMessage() ?></div>
499499
<?php endif; ?>
@@ -732,7 +732,7 @@ You can define as many URL patterns as you need - each is a regular expression.
732732
733733
// app/config/security.php
734734
$container->loadFromExtension('security', array(
735-
...,
735+
// ...
736736
'access_control' => array(
737737
array('path' => '^/admin/users', 'role' => 'ROLE_SUPER_ADMIN'),
738738
array('path' => '^/admin', 'role' => 'ROLE_ADMIN'),
@@ -1082,7 +1082,7 @@ In fact, you've seen this already in the example in this chapter.
10821082
10831083
// app/config/security.php
10841084
$container->loadFromExtension('security', array(
1085-
...,
1085+
// ...
10861086
'providers' => array(
10871087
'default_provider' => array(
10881088
'memory' => array(
@@ -1325,7 +1325,7 @@ configure the encoder for that user:
13251325
13261326
// app/config/security.php
13271327
$container->loadFromExtension('security', array(
1328-
...,
1328+
// ...
13291329
'encoders' => array(
13301330
'Acme\UserBundle\Entity\User' => 'sha512',
13311331
),
@@ -1559,10 +1559,10 @@ the first provider is always used:
15591559
$container->loadFromExtension('security', array(
15601560
'firewalls' => array(
15611561
'secured_area' => array(
1562-
...,
1562+
// ...
15631563
'provider' => 'user_db',
15641564
'http_basic' => array(
1565-
...,
1565+
// ...
15661566
'provider' => 'in_memory',
15671567
),
15681568
'form_login' => array(),
@@ -1674,7 +1674,7 @@ the firewall can handle this automatically for you when you activate the
16741674
'firewalls' => array(
16751675
'secured_area' => array(
16761676
// ...
1677-
'logout' => array('path' => '/logout', 'target' => '/'),
1677+
'logout' => array('path' => 'logout', 'target' => '/'),
16781678
),
16791679
),
16801680
// ...
@@ -1833,7 +1833,7 @@ done by activating the ``switch_user`` firewall listener:
18331833
$container->loadFromExtension('security', array(
18341834
'firewalls' => array(
18351835
'main'=> array(
1836-
...,
1836+
// ...
18371837
'switch_user' => true
18381838
),
18391839
),

book/templating.rst

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -676,9 +676,7 @@ Symfony2 uses the standard ``render`` helper to configure ``hinclude`` tags:
676676

677677
.. code-block:: jinja
678678
679-
{{ render_hinclude(controller('...')) }}
680-
681-
{{ render_hinclude(url('...')) }}
679+
{% render url('...') with {}, {'standalone': 'js'} %}
682680
683681
.. code-block:: php
684682
@@ -1297,20 +1295,24 @@ this classic example:
12971295

12981296
.. configuration-block::
12991297

1300-
.. code-block:: jinja
1298+
.. code-block:: html+jinja
13011299

13021300
Hello {{ name }}
13031301

13041302
.. code-block:: html+php
13051303

13061304
Hello <?php echo $name ?>
13071305

1308-
Imagine that the user enters the following code as his/her name::
1306+
Imagine that the user enters the following code as his/her name:
1307+
1308+
.. code-block:: text
13091309
13101310
<script>alert('hello!')</script>
13111311
13121312
Without any output escaping, the resulting template will cause a JavaScript
1313-
alert box to pop up::
1313+
alert box to pop up:
1314+
1315+
.. code-block:: html
13141316

13151317
Hello <script>alert('hello!')</script>
13161318

@@ -1320,7 +1322,9 @@ inside the secure area of an unknowing, legitimate user.
13201322

13211323
The answer to the problem is output escaping. With output escaping on, the
13221324
same template will render harmlessly, and literally print the ``script``
1323-
tag to the screen::
1325+
tag to the screen:
1326+
1327+
.. code-block:: html
13241328

13251329
Hello &lt;script&gt;alert(&#39;helloe&#39;)&lt;/script&gt;
13261330

@@ -1352,7 +1356,9 @@ Output Escaping in PHP
13521356

13531357
Output escaping is not automatic when using PHP templates. This means that
13541358
unless you explicitly choose to escape a variable, you're not protected. To
1355-
use output escaping, use the special ``escape()`` view method::
1359+
use output escaping, use the special ``escape()`` view method:
1360+
1361+
.. code-block:: html+php
13561362

13571363
Hello <?php echo $view->escape($name) ?>
13581364

@@ -1361,7 +1367,7 @@ within an HTML context (and thus the variable is escaped to be safe for HTML).
13611367
The second argument lets you change the context. For example, to output something
13621368
in a JavaScript string, use the ``js`` context:
13631369

1364-
.. code-block:: js
1370+
.. code-block:: html+php
13651371

13661372
var myMsg = 'Hello <?php echo $view->escape($name, 'js') ?>';
13671373

book/testing.rst

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@ for its ``DemoController`` (`DemoControllerTest`_) that reads as follows::
158158
kernel of your application. In most cases, this happens automatically.
159159
However, if your kernel is in a non-standard directory, you'll need
160160
to modify your ``phpunit.xml.dist`` file to set the ``KERNEL_DIR`` environment
161-
variable to the directory of your kernel::
161+
variable to the directory of your kernel:
162+
163+
.. code-block:: xml
162164
163165
<phpunit>
164166
<!-- ... -->
@@ -352,14 +354,6 @@ or perform more complex requests::
352354
'image/jpeg',
353355
123
354356
);
355-
// or
356-
$photo = array(
357-
'tmp_name' => '/path/to/photo.jpg',
358-
'name' => 'photo.jpg',
359-
'type' => 'image/jpeg',
360-
'size' => 123,
361-
'error' => UPLOAD_ERR_OK
362-
);
363357
$client->request(
364358
'POST',
365359
'/submit',

components/console/introduction.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ You also need to create the file to run at the command line which creates
8585
an ``Application`` and adds commands to it::
8686

8787
#!/usr/bin/env php
88-
# app/console
8988
<?php
89+
// app/console
9090

9191
use Acme\DemoBundle\Command\GreetCommand;
9292
use Symfony\Component\Console\Application;

components/console/single_command_tool.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,32 @@ it is possible to remove this need by extending the application::
4343

4444
return $defaultCommands;
4545
}
46+
47+
/**
48+
* Overridden so that the application doesn't expect the command
49+
* name to be the first argument.
50+
*/
51+
public function getDefinition()
52+
{
53+
$inputDefinition = parent::getDefinition();
54+
// clear out the normal first argument, which is the command name
55+
$inputDefinition->setArguments();
56+
57+
return $inputDefinition;
58+
}
4659
}
4760

4861
When calling your console script, the command `MyCommand` will then always
4962
be used, without having to pass its name.
63+
64+
You can also simplify how you execute the application::
65+
66+
#!/usr/bin/env php
67+
<?php
68+
// command.php
69+
70+
use Acme\Tool\MyApplication;
71+
72+
$application = new MyApplication();
73+
$application->run();
74+

components/event_dispatcher/introduction.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ the ``getOrder`` method::
317317
.. index::
318318
single: Event Dispatcher; Event subscribers
319319

320+
.. _event_dispatcher-using-event-subscribers:
321+
320322
Using Event Subscribers
321323
~~~~~~~~~~~~~~~~~~~~~~~
322324

@@ -389,6 +391,10 @@ indexed by event names and whose values are either the method name to call or
389391
an array composed of the method name to call and a priority. The example
390392
above shows how to register several listener methods for the same event in
391393
subscriber and also shows how to pass the priority of each listener method.
394+
The higher the priority, the earlier the method is called. In the above
395+
example, when the ``kernel.response`` event is triggered, the methods
396+
``onKernelResponsePre``, ``onKernelResponseMid``, and ``onKernelResponsePost``
397+
are called in that order.
392398

393399
.. index::
394400
single: Event Dispatcher; Stopping event flow

components/http_kernel/introduction.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ been streamed to the user
457457

458458
The final event of the HttpKernel process is ``kernel.terminate`` and is unique
459459
because it occurs *after* the ``HttpKernel::handle`` method, and after the
460-
response is send to the user. Recall from above, then the code that uses
460+
response is sent to the user. Recall from above, then the code that uses
461461
the kernel, ends like this::
462462

463463
// echo the content and send the headers

contributing/code/git.rst

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
Git
2+
===
3+
4+
This document explains some conventions and specificities in the way we manage
5+
the Symfony code with Git.
6+
7+
Pull Requests
8+
-------------
9+
10+
Whenever a pull request is merged, all the information contained in the pull
11+
request (including comments) is saved in the repository.
12+
13+
You can easily spot pull request merges as the commit message always follows
14+
this pattern:
15+
16+
.. block: text
17+
18+
merged branch USER_NAME/BRANCH_NAME (PR #1111)
19+
20+
The PR reference allows you to have a look at the original pull request on
21+
Github: https://github.com/symfony/symfony/pull/1111. But all the information
22+
you can get on Github is also available from the repository itself.
23+
24+
The merge commit message contains the original message from the author of the
25+
changes. Often, this can help understand what the changes were about and the
26+
reasoning behind the changes.
27+
28+
Moreover, the full discussion that might have occurred back then is also
29+
stored as a Git note (before March 22 2013, the discussion was part of the
30+
main merge commit message). To get access to these notes, add this line to
31+
your ``.git/config`` file:
32+
33+
.. block: text
34+
35+
fetch = +refs/notes/*:refs/notes/*
36+
37+
After a fetch, getting the Github discussion for a commit is then a matter of
38+
adding ``--show-notes=github-comments`` to the ``git show`` command:
39+
40+
.. block: text
41+
42+
git show HEAD --show-notes=github-comments

contributing/code/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ Contributing Code
1010
tests
1111
standards
1212
conventions
13+
git
1314
license

0 commit comments

Comments
 (0)