Skip to content

Commit ff44111

Browse files
committed
Merge branch '2.3' into 2.5
* 2.3: (45 commits) More xml fixes Xml changes and line-break changes Swiched mydomain and specialdomain Changes recommended by @cordoval Changes recommended by @javierguiluz Changed line-breaks in text Added improvments from @wouterj fixed typo in "except" Document whitelist option to email redirect Typo Improve assetic:watch text Update asset_management.rst Link to standard edition so users can get the app/AppKernel.php if needed. Update tests.rst ensure consistency with the note Update security.rst minor #4977 Unnecessary comma (edsonmedina) Wrong comma file extension fix Fixed some syntax issues in Twig Reference ... Conflicts: cookbook/session/index.rst reference/twig_reference.rst
2 parents 73a7c0c + f75bc2b commit ff44111

28 files changed

+212
-79
lines changed

Diff for: best_practices/business-logic.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ The blog application needs a utility that can transform a post title (e.g.
5656
"Hello World") into a slug (e.g. "hello-world"). The slug will be used as
5757
part of the post URL.
5858

59-
Let's, create a new ``Slugger`` class inside ``src/AppBundle/Utils/`` and
59+
Let's create a new ``Slugger`` class inside ``src/AppBundle/Utils/`` and
6060
add the following ``slugify()`` method:
6161

6262
.. code-block:: php

Diff for: best_practices/tests.rst

+26-16
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,35 @@ A functional test can be as easy as this:
3030

3131
.. code-block:: php
3232
33-
/** @dataProvider provideUrls */
34-
public function testPageIsSuccessful($url)
35-
{
36-
$client = self::createClient();
37-
$client->request('GET', $url);
33+
// src/AppBundle/Tests/ApplicationAvailabilityFunctionalTest.php
34+
namespace AppBundle\Tests;
3835
39-
$this->assertTrue($client->getResponse()->isSuccessful());
40-
}
36+
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
4137
42-
public function provideUrls()
38+
class ApplicationAvailabilityFunctionalTest extends WebTestCase
4339
{
44-
return array(
45-
array('/'),
46-
array('/posts'),
47-
array('/post/fixture-post-1'),
48-
array('/blog/category/fixture-category'),
49-
array('/archives'),
50-
// ...
51-
);
40+
/**
41+
* @dataProvider urlProvider
42+
*/
43+
public function testPageIsSuccessful($url)
44+
{
45+
$client = self::createClient();
46+
$client->request('GET', $url);
47+
48+
$this->assertTrue($client->getResponse()->isSuccessful());
49+
}
50+
51+
public function urlProvider()
52+
{
53+
return array(
54+
array('/'),
55+
array('/posts'),
56+
array('/post/fixture-post-1'),
57+
array('/blog/category/fixture-category'),
58+
array('/archives'),
59+
// ...
60+
);
61+
}
5262
}
5363
5464
This code checks that all the given URLs load successfully, which means that

Diff for: book/controller.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ Controllers are also called *actions*.
116116

117117
This controller is pretty straightforward:
118118

119-
* *line 4*: Symfony takes advantage of PHP 5.3 namespace functionality to
119+
* *line 4*: Symfony takes advantage of PHP's namespace functionality to
120120
namespace the entire controller class. The ``use`` keyword imports the
121121
``Response`` class, which the controller must return.
122122

Diff for: book/from_flat_php_to_symfony2.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ A routing configuration map provides this information in a readable format:
649649
650650
Now that Symfony is handling all the mundane tasks, the front controller
651651
is dead simple. And since it does so little, you'll never have to touch
652-
it once it's created (and if you use a Symfony distribution, you won't
652+
it once it's created (and if you use a `Symfony distribution`_, you won't
653653
even need to create it!)::
654654

655655
// web/app.php
@@ -764,3 +764,4 @@ Learn more from the Cookbook
764764
.. _`Twig`: http://twig.sensiolabs.org
765765
.. _`Varnish`: https://www.varnish-cache.org/
766766
.. _`PHPUnit`: http://www.phpunit.de
767+
.. _`Symfony distribution`: https://github.com/symfony/symfony-standard

Diff for: book/security.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ is both flexible and (hopefully) fun to work with.
1414
Since there's a lot to talk about, this chapter is organized into a few big
1515
sections:
1616

17-
1) Initial ``security.yml`` setup (*authentication*);
17+
#. Initial ``security.yml`` setup (*authentication*);
1818

19-
2) Denying access to your app (*authorization*);
19+
#. Denying access to your app (*authorization*);
2020

21-
3) Fetching the current User object
21+
#. Fetching the current User object.
2222

2323
These are followed by a number of small (but still captivating) sections,
2424
like :ref:`logging out <book-security-logging-out>` and :ref:`encoding user passwords <security-encoding-password>`.
@@ -492,7 +492,7 @@ else, you'll want to encode their passwords. The best algorithm to use is
492492
493493
'encoders' => array(
494494
'Symfony\Component\Security\Core\User\User' => array(
495-
'algorithm' => 'plaintext',
495+
'algorithm' => 'bcrypt',
496496
'cost' => 12,
497497
)
498498
),

Diff for: book/testing.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,8 @@ and pass it a ``Link`` object::
619619
Forms
620620
~~~~~
621621

622-
Just like links, you select forms with the ``selectButton()`` method::
622+
Forms can be selected using their buttons, which can be selected with the
623+
``selectButton()`` method, just like links::
623624

624625
$buttonCrawlerNode = $crawler->selectButton('submit');
625626

Diff for: book/validation.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,7 @@ By calling ``validate`` on the validator, you can pass in a raw value and
12521252
the constraint object that you want to validate that value against. A full
12531253
list of the available constraints - as well as the full class name for each
12541254
constraint - is available in the :doc:`constraints reference </reference/constraints>`
1255-
section .
1255+
section.
12561256

12571257
The ``validate`` method returns a :class:`Symfony\\Component\\Validator\\ConstraintViolationList`
12581258
object, which acts just like an array of errors. Each error in the collection

Diff for: components/class_loader/map_class_loader.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Usage
2525
Using it is as easy as passing your mapping to its constructor when creating
2626
an instance of the ``MapClassLoader`` class::
2727

28-
require_once '/path/to/src/Symfony/Component/ClassLoader/MapClassLoader';
28+
require_once '/path/to/src/Symfony/Component/ClassLoader/MapClassLoader.php';
2929

3030
$mapping = array(
3131
'Foo' => '/path/to/Foo',

Diff for: components/console/events.rst

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ the wheel, it uses the Symfony EventDispatcher component to do the work::
2020
$application->setDispatcher($dispatcher);
2121
$application->run();
2222

23+
.. caution::
24+
25+
Console events are only triggered by the main command being executed.
26+
Commands called by the main command will not trigger any event.
27+
2328
The ``ConsoleEvents::COMMAND`` Event
2429
------------------------------------
2530

Diff for: components/http_foundation/introduction.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ Serving Files
480480
When sending a file, you must add a ``Content-Disposition`` header to your
481481
response. While creating this header for basic file downloads is easy, using
482482
non-ASCII filenames is more involving. The
483-
:method:`Symfony\\Component\\HttpFoundation\\Response::makeDisposition`
483+
:method:`Symfony\\Component\\HttpFoundation\\ResponseHeaderBag::makeDisposition`
484484
abstracts the hard work behind a simple API::
485485

486486
use Symfony\Component\HttpFoundation\ResponseHeaderBag;

Diff for: components/translation/usage.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ recommended format. These files are parsed by one of the loader classes.
217217
'symfony.is.great' => 'Symfony is great',
218218
'symfony.is.amazing' => 'Symfony is amazing',
219219
'symfony.has.bundles' => 'Symfony has bundles',
220-
'user.login' => 'Login',
220+
'user.login' => 'Login',
221221
);
222222
223223
.. _component-translation-pluralization:

Diff for: components/yaml/yaml_format.rst

+8-8
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,14 @@ The following YAML is equivalent to the following PHP code:
228228
.. code-block:: php
229229
230230
array(
231-
'symfony 1.0' => array(
232-
'PHP' => 5.0,
233-
'Propel' => 1.2,
234-
),
235-
'symfony 1.2' => array(
236-
'PHP' => 5.2,
237-
'Propel' => 1.3,
238-
),
231+
'symfony 1.0' => array(
232+
'PHP' => 5.0,
233+
'Propel' => 1.2,
234+
),
235+
'symfony 1.2' => array(
236+
'PHP' => 5.2,
237+
'Propel' => 1.3,
238+
),
239239
);
240240
241241
There is one important thing you need to remember when using indentation in a

Diff for: cookbook/assetic/asset_management.rst

+7-3
Original file line numberDiff line numberDiff line change
@@ -540,12 +540,16 @@ need to dump them manually. To do so, run the following:
540540
541541
This physically writes all of the asset files you need for your ``dev``
542542
environment. The big disadvantage is that you need to run this each time
543-
you update an asset. Fortunately, by passing the ``--watch`` option, the
544-
command will automatically regenerate assets *as they change*:
543+
you update an asset. Fortunately, by using the ``assetic:watch`` command,
544+
assets will be regenerated automatically *as they change*:
545545

546546
.. code-block:: bash
547547
548-
$ php app/console assetic:dump --watch
548+
$ php app/console assetic:watch
549+
550+
The ``assetic:watch`` command was introduced in AsseticBundle 2.4. In prior
551+
versions, you had to use the ``--watch`` option of the ``assetic:dump``
552+
command for the same behavior.
549553

550554
Since running this command in the ``dev`` environment may generate a bunch
551555
of files, it's usually a good idea to point your generated asset files to

Diff for: cookbook/bundles/best_practices.rst

+3-4
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@ Bundle Name
2929
-----------
3030

3131
A bundle is also a PHP namespace. The namespace must follow the technical
32-
interoperability `standards`_ for PHP 5.3 namespaces and class names: it
33-
starts with a vendor segment, followed by zero or more category segments, and
34-
it ends with the namespace short name, which must end with a ``Bundle``
35-
suffix.
32+
interoperability `standards`_ for PHP namespaces and class names: it starts
33+
with a vendor segment, followed by zero or more category segments, and it ends
34+
with the namespace short name, which must end with a ``Bundle`` suffix.
3635

3736
A namespace becomes a bundle as soon as you add a bundle class to it. The
3837
bundle class name must follow these simple rules:

Diff for: cookbook/cache/varnish.rst

+4-5
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,10 @@ If you know for sure that the backend never uses sessions or basic
7272
authentication, have varnish remove the corresponding header from requests to
7373
prevent clients from bypassing the cache. In practice, you will need sessions
7474
at least for some parts of the site, e.g. when using forms with
75-
:ref:`CSRF Protection <forms-csrf>`. In this situation, make sure to only
76-
start a session when actually needed, and clear the session when it is no
77-
longer needed. Alternatively, you can look into :doc:`../cache/form_csrf_caching`.
78-
79-
.. todo link "only start a session when actually needed" to cookbook/session/avoid_session_start once https://github.com/symfony/symfony-docs/pull/4661 is merged
75+
:ref:`CSRF Protection <forms-csrf>`. In this situation, make sure to
76+
:doc:`only start a session when actually needed </cookbook/session/avoid_session_start>`
77+
and clear the session when it is no longer needed. Alternatively, you can look
78+
into :doc:`/cookbook/cache/form_csrf_caching`.
8079

8180
Cookies created in Javascript and used only in the frontend, e.g. when using
8281
Google analytics are nonetheless sent to the server. These cookies are not

Diff for: cookbook/doctrine/file_uploads.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ rules::
181181
182182
.. code-block:: xml
183183
184-
<!-- src/AppBundle/Resources/config/validation.yml -->
184+
<!-- src/AppBundle/Resources/config/validation.xml -->
185185
<class name="AppBundle\Entity\Document">
186186
<property name="file">
187187
<constraint name="File">

Diff for: cookbook/email/dev_environment.rst

+62-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ can easily achieve this through configuration settings without having to
1111
make any changes to your application's code at all. There are two main
1212
choices when it comes to handling email during development: (a) disabling the
1313
sending of email altogether or (b) sending all email to a specific
14-
address.
14+
address (with optional exceptions).
1515

1616
Disabling Sending
1717
-----------------
@@ -119,6 +119,67 @@ the replaced address, so you can still see who it would have been sent to.
119119
These are ``X-Swift-Cc`` and ``X-Swift-Bcc`` for the ``CC`` and ``BCC``
120120
addresses respectively.
121121

122+
Sending to a Specified Address but with Exceptions
123+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
124+
125+
Suppose you want to have all email redirected to a specific address,
126+
(like in the above scenario to ``dev@example.com``). But then you may want
127+
email sent to some specific email addresses to go through after all, and
128+
not be redirected (even if it is in the dev environment). This can be done
129+
by adding the ``delivery_whitelist`` option:
130+
131+
.. configuration-block::
132+
133+
.. code-block:: yaml
134+
135+
# app/config/config_dev.yml
136+
swiftmailer:
137+
delivery_address: dev@example.com
138+
delivery_whitelist:
139+
# all email addresses matching this regex will *not* be
140+
# redirected to dev@example.com
141+
- "/@specialdomain.com$/"
142+
143+
# all emails sent to admin@mydomain.com won't
144+
# be redirected to dev@example.com too
145+
- "/^admin@mydomain.com$/"
146+
147+
.. code-block:: xml
148+
149+
<!-- app/config/config_dev.xml -->
150+
151+
<?xml version="1.0" charset="UTF-8" ?>
152+
<container xmlns="http://symfony.com/schema/dic/services"
153+
xmlns:swiftmailer="http://symfony.com/schema/dic/swiftmailer">
154+
155+
<swiftmailer:config delivery-address="dev@example.com">
156+
<!-- all email addresses matching this regex will *not* be redirected to dev@example.com -->
157+
<swiftmailer:delivery-whitelist-pattern>/@specialdomain.com$/</swiftmailer:delivery-whitelist-pattern>
158+
159+
<!-- all emails sent to admin@mydomain.com won't be redirected to dev@example.com too -->
160+
<swiftmailer:delivery-whitelist-pattern>/^admin@mydomain.com$/</swiftmailer:delivery-whitelist-pattern>
161+
</swiftmailer:config>
162+
163+
.. code-block:: php
164+
165+
// app/config/config_dev.php
166+
$container->loadFromExtension('swiftmailer', array(
167+
'delivery_address' => "dev@example.com",
168+
'delivery_whitelist' => array(
169+
// all email addresses matching this regex will *not* be
170+
// redirected to dev@example.com
171+
'/@specialdomain.com$/',
172+
173+
// all emails sent to admin@mydomain.com won't be
174+
// redirected to dev@example.com too
175+
'/^admin@mydomain.com$/',
176+
),
177+
));
178+
179+
In the above example all email messages will be redirected to ``dev@example.com``,
180+
except messages sent to the ``admin@mydomain.com`` address or to any email
181+
address belonging to the domain ``specialdomain.com``, which will be delivered as normal.
182+
122183
Viewing from the Web Debug Toolbar
123184
----------------------------------
124185

Diff for: cookbook/event_dispatcher/before_after_filters.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ your listener to be called just before any controller is executed.
156156
# app/config/services.yml
157157
services:
158158
app.tokens.action_listener:
159-
class: AappBundle\EventListener\TokenListener
159+
class: AppBundle\EventListener\TokenListener
160160
arguments: ["%tokens%"]
161161
tags:
162162
- { name: kernel.event_listener, event: kernel.controller, method: onKernelController }
@@ -240,7 +240,7 @@ if it's found::
240240
$response->headers->set('X-CONTENT-HASH', $hash);
241241
}
242242

243-
Finally, a second "tag" is needed on the service definition to notify Symfony
243+
Finally, a second "tag" is needed in the service definition to notify Symfony
244244
that the ``onKernelResponse`` event should be notified for the ``kernel.response``
245245
event:
246246

Diff for: cookbook/form/create_form_type_extension.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ For more information on what those methods do, you can refer to the
9292
cookbook article.
9393

9494
Registering your Form Type Extension as a Service
95-
--------------------------------------------------
95+
-------------------------------------------------
9696

9797
The next step is to make Symfony aware of your extension. All you
9898
need to do is to declare it as a service by using the ``form.type_extension``
@@ -290,7 +290,7 @@ Specifically, you need to override the ``file_widget`` block:
290290
information.
291291

292292
Using the Form Type Extension
293-
------------------------------
293+
-----------------------------
294294

295295
From now on, when adding a field of type ``file`` in your form, you can
296296
specify an ``image_path`` option that will be used to display an image

Diff for: cookbook/form/dynamic_form_modification.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -712,10 +712,11 @@ all of this, use a listener::
712712

713713
use Symfony\Component\Form\FormBuilderInterface;
714714
use Symfony\Component\Form\FormEvents;
715+
use Symfony\Component\Form\FormEvent;
715716

716717
public function buildForm(FormBuilderInterface $builder, array $options)
717718
{
718-
$builder->addEventListener(FormEvents::POST_SUBMIT, function ($event) {
719+
$builder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) {
719720
$event->stopPropagation();
720721
}, 900); // Always set a higher priority than ValidationListener
721722

Diff for: cookbook/logging/monolog.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
How to Use Monolog to Write Logs
55
================================
66

7-
Monolog_ is a logging library for PHP 5.3 used by Symfony. It is
8-
inspired by the Python LogBook library.
7+
Monolog_ is a logging library for PHP used by Symfony. It is inspired by the
8+
Python LogBook library.
99

1010
Usage
1111
-----

Diff for: cookbook/logging/monolog_email.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ it is broken down.
2323
action_level: critical
2424
# to also log 400 level errors (but not 404's):
2525
# action_level: error
26-
# excluded_404:
26+
# excluded_404s:
2727
# - ^/
2828
handler: buffered
2929
buffered:

0 commit comments

Comments
 (0)