Skip to content

Commit 8566263

Browse files
committed
Merge branch '2.6' into 2.7
* 2.6: (45 commits) Removed duplicate "long"s terminate file with newline move title back and move description to separate file as suggested in PR #4892 move title out of included file as suggested in PR #4892 Add possible values for widget_type [#4842] Making 2 sentences changes as suggested by WouterJ in pull request #4842 Add meaning of yellow icon for number of queries Fixing bad link name fix typo in event flow diagrams Many fixes thanks to stof, WouterJ, xabbuh and dupuchba added Jakub as a merger for the DomCrawler component [#5094] Removing mkdir - it's not needed (thanks xabbuh) some tweaks to #4601 Moving index down to correct section [#4989] Language tweaks and making the example simpler Remove useless setLocale() call and add code block with locale setter Finaly touches on translation locale setting note Review note about setting the translator locale in a controller. Update translation.rst ...
2 parents d6a838a + b91f05d commit 8566263

35 files changed

+477
-491
lines changed

Diff for: best_practices/forms.rst

+18
Original file line numberDiff line numberDiff line change
@@ -207,3 +207,21 @@ Second, we recommend using ``$form->isSubmitted()`` in the ``if`` statement
207207
for clarity. This isn't technically needed, since ``isValid()`` first calls
208208
``isSubmitted()``. But without this, the flow doesn't read well as it *looks*
209209
like the form is *always* processed (even on the GET request).
210+
211+
Custom Form Field Types
212+
-----------------------
213+
214+
.. best-practice::
215+
216+
Add the ``app_`` prefix to your custom form field types to avoid collisions.
217+
218+
Custom form field types inherit from the ``AbstractType`` class, which defines the
219+
``getName()`` method to configure the name of that form type. These names must
220+
be unique in the application.
221+
222+
If a custom form type uses the same name as any of the Symfony's built-in form
223+
types, it will override it. The same happens when the custom form type matches
224+
any of the types defined by the third-party bundles installed in your application.
225+
226+
Add the ``app_`` prefix to your custom form field types to avoid name collisions
227+
that can lead to hard to debug errors.

Diff for: book/controller.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ Or, if you want to redirect externally, just use ``redirect()`` and pass it the
451451
}
452452

453453
By default, the ``redirectToRoute()`` method performs a 302 (temporary) redirect. To
454-
perform a 301 (permanent) redirect, modify the second argument::
454+
perform a 301 (permanent) redirect, modify the third argument::
455455

456456
public function indexAction()
457457
{

Diff for: book/doctrine.rst

+3
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,9 @@ to easily fetch objects based on multiple conditions::
646646

647647
If you click the icon, the profiler will open, showing you the exact
648648
queries that were made.
649+
650+
The icon will turn yellow if there were more than 50 queries on the
651+
page. This could indicate that something is not correct.
649652

650653
Updating an Object
651654
~~~~~~~~~~~~~~~~~~

Diff for: book/forms.rst

+10-3
Original file line numberDiff line numberDiff line change
@@ -1061,9 +1061,16 @@ that will house the logic for building the task form::
10611061
}
10621062
}
10631063

1064-
This new class contains all the directions needed to create the task form
1065-
(note that the ``getName()`` method should return a unique identifier for this
1066-
form "type"). It can be used to quickly build a form object in the controller::
1064+
.. caution::
1065+
1066+
The ``getName()`` method returns the identifier of this form "type". These
1067+
identifiers must be unique in the application. Unless you want to override
1068+
a built-in type, they should be different from the default Symfony types
1069+
and from any type defined by a third-party bundle installed in your application.
1070+
Consider prefixing your types with ``app_`` to avoid identifier collisions.
1071+
1072+
This new class contains all the directions needed to create the task form. It can
1073+
be used to quickly build a form object in the controller::
10671074

10681075
// src/AppBundle/Controller/DefaultController.php
10691076

Diff for: book/http_fundamentals.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ by adding an entry for ``/contact`` to your routing configuration file:
460460
461461
When someone visits the ``/contact`` page, this route is matched, and the
462462
specified controller is executed. As you'll learn in the :doc:`routing chapter </book/routing>`,
463-
the ``AcmeDemoBundle:Main:contact`` string is a short syntax that points to a
463+
the ``AppBundle:Main:contact`` string is a short syntax that points to a
464464
specific PHP method ``contactAction`` inside a class called ``MainController``::
465465

466466
// src/AppBundle/Controller/MainController.php

Diff for: book/translation.rst

+21-7
Original file line numberDiff line numberDiff line change
@@ -427,17 +427,28 @@ via the ``request`` object::
427427
public function indexAction(Request $request)
428428
{
429429
$locale = $request->getLocale();
430-
431-
$request->setLocale('en_US');
432430
}
433431

434-
.. tip::
432+
To set the user's locale, you may want to create a custom event listener
433+
so that it's set before any other parts of the system (i.e. the translator)
434+
need it::
435435

436-
Read :doc:`/cookbook/session/locale_sticky_session` to learn how to store
437-
the user's locale in the session.
436+
public function onKernelRequest(GetResponseEvent $event)
437+
{
438+
$request = $event->getRequest();
438439

439-
.. index::
440-
single: Translations; Fallback and default locale
440+
// some logic to determine the $locale
441+
$request->getSession()->set('_locale', $locale);
442+
}
443+
444+
Read :doc:`/cookbook/session/locale_sticky_session` for more on the topic.
445+
446+
.. note::
447+
448+
Setting the locale using ``$request->setLocale()`` in the controller
449+
is too late to affect the translator. Either set the locale via a listener
450+
(like above), the URL (see next) or call ``setLocale()`` directly on
451+
the ``translator`` service.
441452

442453
See the :ref:`book-translation-locale-url` section below about setting the
443454
locale via routing.
@@ -518,6 +529,9 @@ in your application.
518529
Read :doc:`/cookbook/routing/service_container_parameters` to learn how to
519530
avoid hardcoding the ``_locale`` requirement in all your routes.
520531

532+
.. index::
533+
single: Translations; Fallback and default locale
534+
521535
Setting a default Locale
522536
~~~~~~~~~~~~~~~~~~~~~~~~
523537

Diff for: components/using_components.rst

+2-7
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@ whatever component you want.
3636
file in your directory. In that case, no worries! Just run
3737
``php composer.phar require symfony/finder``.
3838

39-
If you know you need a specific version of the library, add that to the command:
40-
41-
.. code-block:: bash
42-
43-
$ composer require symfony/finder
44-
4539
**3.** Write your code!
4640

4741
Once Composer has downloaded the component(s), all you need to do is include
@@ -51,7 +45,8 @@ immediately::
5145

5246
// File example: src/script.php
5347

54-
// update this to the path to the "vendor/" directory, relative to this file
48+
// update this to the path to the "vendor/"
49+
// directory, relative to this file
5550
require_once __DIR__.'/../vendor/autoload.php';
5651

5752
use Symfony\Component\Finder\Finder;

Diff for: contributing/code/core_team.rst

+11-3
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,19 @@ Active Core Members
6060
MonologBridge_, and TwigBridge_ components;
6161

6262
* **Kévin Dunglas** (`dunglas`_) can merge into the Serializer_
63-
component.
63+
component;
64+
65+
* **Abdellatif AitBoudad** (`aitboudad`_) can merge into the Translation_
66+
component;
67+
68+
* **Jakub Zalas** (`jakzal`_) can merge into the DomCrawler_ component.
6469

6570
* **Deciders** (``@symfony/deciders`` on GitHub):
6671

67-
* **Jakub Zalas** (`jakzal`_);
6872
* **Jordi Boggiano** (`seldaek`_);
6973
* **Lukas Kahwe Smith** (`lsmith77`_);
70-
* **Ryan Weaver** (`weaverryan`_).
74+
* **Ryan Weaver** (`weaverryan`_);
75+
* **Christian Flothmann** (`xabbuh`_).
7176

7277
Core Membership Application
7378
~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -165,6 +170,7 @@ discretion of the **Project Leader**.
165170
.. _PropertyAccess: https://github.com/symfony/PropertyAccess
166171
.. _Routing: https://github.com/symfony/Routing
167172
.. _Serializer: https://github.com/symfony/Serializer
173+
.. _Translation: https://github.com/symfony/Translation
168174
.. _Stopwatch: https://github.com/symfony/Stopwatch
169175
.. _TwigBridge: https://github.com/symfony/TwigBridge
170176
.. _Validator: https://github.com/symfony/Validator
@@ -181,3 +187,5 @@ discretion of the **Project Leader**.
181187
.. _`Seldaek`: https://github.com/Seldaek/
182188
.. _`lsmith77`: https://github.com/lsmith77/
183189
.. _`weaverryan`: https://github.com/weaverryan/
190+
.. _`aitboudad`: https://github.com/aitboudad/
191+
.. _`xabbuh`: https://github.com/xabbuh/

Diff for: cookbook/assetic/apply_to_option.rst

+10-11
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ as you'll see here, files that have a specific extension. To show you how
99
to handle each option, suppose that you want to use Assetic's CoffeeScript
1010
filter, which compiles CoffeeScript files into JavaScript.
1111

12-
The main configuration is just the paths to coffee, node and node_modules.
12+
The main configuration is just the paths to ``coffee``, ``node`` and ``node_modules``.
1313
An example configuration might look like this:
1414

1515
.. configuration-block::
@@ -102,8 +102,7 @@ You can also combine multiple CoffeeScript files into a single output file:
102102
<script src="<?php echo $view->escape($url) ?>"></script>
103103
<?php endforeach ?>
104104

105-
Both the files will now be served up as a single file compiled into regular
106-
JavaScript.
105+
Both files will now be served up as a single file compiled into regular JavaScript.
107106

108107
.. _cookbook-assetic-apply-to:
109108

@@ -117,10 +116,10 @@ since they will ultimately all be served as JavaScript. Unfortunately just
117116
adding the JavaScript files to the files to be combined as above will not
118117
work as the regular JavaScript files will not survive the CoffeeScript compilation.
119118

120-
This problem can be avoided by using the ``apply_to`` option in the config,
121-
which allows you to specify which filter should always be applied to particular
122-
file extensions. In this case you can specify that the ``coffee`` filter is
123-
applied to all ``.coffee`` files:
119+
This problem can be avoided by using the ``apply_to`` option, which allows you
120+
to specify which filter should always be applied to particular file extensions.
121+
In this case you can specify that the ``coffee`` filter is applied to all
122+
``.coffee`` files:
124123

125124
.. configuration-block::
126125

@@ -161,10 +160,10 @@ applied to all ``.coffee`` files:
161160
),
162161
));
163162
164-
With this, you no longer need to specify the ``coffee`` filter in the template.
165-
You can also list regular JavaScript files, all of which will be combined
166-
and rendered as a single JavaScript file (with only the ``.coffee`` files
167-
being run through the CoffeeScript filter):
163+
With this option, you no longer need to specify the ``coffee`` filter in the
164+
template. You can also list regular JavaScript files, all of which will be
165+
combined and rendered as a single JavaScript file (with only the ``.coffee``
166+
files being run through the CoffeeScript filter):
168167

169168
.. configuration-block::
170169

Diff for: cookbook/assetic/asset_management.rst

+17-17
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ To include JavaScript files, use the ``javascripts`` tag in any template:
7373
7474
.. note::
7575

76-
If you're using the default block names from the Symfony Standard Edition,
77-
the ``javascripts`` tag will most commonly live in the ``javascripts``
78-
block:
76+
If your application templates use the default block names from the Symfony
77+
Standard Edition, the ``javascripts`` tag will most commonly live in the
78+
``javascripts`` block:
7979

8080
.. code-block:: html+jinja
8181

@@ -108,8 +108,8 @@ that reference images by their relative path. See :ref:`cookbook-assetic-cssrewr
108108
Including CSS Stylesheets
109109
~~~~~~~~~~~~~~~~~~~~~~~~~
110110

111-
To bring in CSS stylesheets, you can use the same methodologies seen
112-
above, except with the ``stylesheets`` tag:
111+
To bring in CSS stylesheets, you can use the same technique explained above,
112+
except with the ``stylesheets`` tag:
113113

114114
.. configuration-block::
115115

@@ -130,9 +130,9 @@ above, except with the ``stylesheets`` tag:
130130
131131
.. note::
132132

133-
If you're using the default block names from the Symfony Standard Edition,
134-
the ``stylesheets`` tag will most commonly live in the ``stylesheets``
135-
block:
133+
If your application templates use the default block names from the Symfony
134+
Standard Edition, the ``stylesheets`` tag will most commonly live in the
135+
``stylesheets`` block:
136136

137137
.. code-block:: html+jinja
138138

@@ -204,7 +204,7 @@ Combining Assets
204204
~~~~~~~~~~~~~~~~
205205

206206
One feature of Assetic is that it will combine many files into one. This helps
207-
to reduce the number of HTTP requests, which is great for front end performance.
207+
to reduce the number of HTTP requests, which is great for frontend performance.
208208
It also allows you to maintain the files more easily by splitting them into
209209
manageable parts. This can help with re-usability as you can easily split
210210
project-specific files from those which can be used in other applications,
@@ -350,7 +350,7 @@ Filters
350350

351351
Once they're managed by Assetic, you can apply filters to your assets before
352352
they are served. This includes filters that compress the output of your assets
353-
for smaller file sizes (and better front-end optimization). Other filters
353+
for smaller file sizes (and better frontend optimization). Other filters
354354
can compile JavaScript file from CoffeeScript files and process SASS into CSS.
355355
In fact, Assetic has a long list of available filters.
356356

@@ -366,8 +366,8 @@ To use a filter, you first need to specify it in the Assetic configuration.
366366
Adding a filter here doesn't mean it's being used - it just means that it's
367367
available to use (you'll use the filter below).
368368

369-
For example to use the UglifyJS JavaScript minifier the following config should
370-
be added:
369+
For example to use the UglifyJS JavaScript minifier the following configuration
370+
should be defined:
371371

372372
.. configuration-block::
373373

@@ -489,8 +489,8 @@ environment is just too slow.
489489

490490
.. _cookbook-assetic-dump-prod:
491491

492-
Instead, each time you use your app in the ``prod`` environment (and therefore,
493-
each time you deploy), you should run the following task:
492+
Instead, each time you use your application in the ``prod`` environment (and therefore,
493+
each time you deploy), you should run the following command:
494494

495495
.. code-block:: bash
496496
@@ -532,7 +532,7 @@ the following change in your ``config_dev.yml`` file:
532532
));
533533
534534
Next, since Symfony is no longer generating these assets for you, you'll
535-
need to dump them manually. To do so, run the following:
535+
need to dump them manually. To do so, run the following command:
536536

537537
.. code-block:: bash
538538
@@ -547,8 +547,8 @@ assets will be regenerated automatically *as they change*:
547547
548548
$ php app/console assetic:watch
549549
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``
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``
552552
command for the same behavior.
553553

554554
Since running this command in the ``dev`` environment may generate a bunch

Diff for: cookbook/assetic/jpeg_optimize.rst

+14-17
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ for your end users.
1313
Using Jpegoptim
1414
---------------
1515

16-
`Jpegoptim`_ is a utility for optimizing JPEG files. To use it with Assetic,
17-
add the following to the Assetic config:
16+
`Jpegoptim`_ is a utility for optimizing JPEG files. To use it with Assetic, make
17+
sure to have it already installed on your system and then, configure its location
18+
using the ``bin`` option of the ``jpegoptim`` filter:
1819

1920
.. configuration-block::
2021

@@ -46,11 +47,6 @@ add the following to the Assetic config:
4647
),
4748
));
4849
49-
.. note::
50-
51-
Notice that to use jpegoptim, you must have it already installed on your
52-
system. The ``bin`` option points to the location of the compiled binary.
53-
5450
It can now be used from a template:
5551

5652
.. configuration-block::
@@ -74,9 +70,9 @@ It can now be used from a template:
7470
Removing all EXIF Data
7571
~~~~~~~~~~~~~~~~~~~~~~
7672

77-
By default, running this filter only removes some of the meta information
78-
stored in the file. Any EXIF data and comments are not removed, but you can
79-
remove these by using the ``strip_all`` option:
73+
By default, the ``jpegoptim`` filter removes some of the meta information stored
74+
in the image. To remove all EXIF data and comments, set the ``strip_all`` option
75+
to ``true``:
8076

8177
.. configuration-block::
8278

@@ -111,13 +107,13 @@ remove these by using the ``strip_all`` option:
111107
),
112108
));
113109
114-
Lowering maximum Quality
110+
Lowering Maximum Quality
115111
~~~~~~~~~~~~~~~~~~~~~~~~
116112

117-
The quality level of the JPEG is not affected by default. You can gain
118-
further file size reductions by setting the max quality setting lower than
119-
the current level of the images. This will of course be at the expense of
120-
image quality:
113+
By default, the ``jpegoptim`` filter doesn't alter the quality level of the JPEG
114+
image. Use the ``max`` option to configure the maximum quality setting (in a
115+
scale of ``0`` to ``100``). The reduction in the image file size will of course
116+
be at the expense of its quality:
121117

122118
.. configuration-block::
123119

@@ -157,7 +153,7 @@ Shorter Syntax: Twig Function
157153

158154
If you're using Twig, it's possible to achieve all of this with a shorter
159155
syntax by enabling and using a special Twig function. Start by adding the
160-
following config:
156+
following configuration:
161157

162158
.. configuration-block::
163159

@@ -206,7 +202,8 @@ The Twig template can now be changed to the following:
206202

207203
<img src="{{ jpegoptim('@AppBundle/Resources/public/images/example.jpg') }}" alt="Example"/>
208204

209-
You can specify the output directory in the config in the following way:
205+
You can also specify the output directory for images in the Assetic configuration
206+
file:
210207

211208
.. configuration-block::
212209

0 commit comments

Comments
 (0)