Skip to content

Commit 82ba7db

Browse files
committed
Merge branch '2.3' into 2.7
* 2.3: [#6219] some tweaks Point that route parameters are also Request attributes [#6348] some minor tweaks [best practices] mostly typos [#6275] some minor tweaks [quick tour] mostly typos remove link-local IPv6 address (fe80::1) [#6305] move link reference to the bottom Mention IvoryCKEditorBundle in the Symfony Forms doc [#6328] minor tweak Update extension.rst - added caution box for people trying to remove the default file with services definitions Altered single / multiple inheritance sentence Replace XLIFF number ids by strings
2 parents a84b2c5 + 72b47e1 commit 82ba7db

19 files changed

+112
-87
lines changed

best_practices/business-logic.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ The three entities defined by our sample blog application are a good example:
193193
Doctrine Mapping Information
194194
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
195195

196-
Doctrine Entities are plain PHP objects that you store in some "database".
196+
Doctrine entities are plain PHP objects that you store in some "database".
197197
Doctrine only knows about your entities through the mapping metadata configured
198198
for your model classes. Doctrine supports four metadata formats: YAML, XML,
199199
PHP and annotations.

best_practices/configuration.rst

+1-3
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ If you've done something like this in the past, it's likely that you've in fact
107107
*never* actually needed to change that value. Creating a configuration
108108
option for a value that you are never going to configure just isn't necessary.
109109
Our recommendation is to define these values as constants in your application.
110-
You could, for example, define a ``NUM_ITEMS`` constant in the ``Post`` entity:
111-
112-
.. code-block:: php
110+
You could, for example, define a ``NUM_ITEMS`` constant in the ``Post`` entity::
113111

114112
// src/AppBundle/Entity/Post.php
115113
namespace AppBundle\Entity;

best_practices/controllers.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Template Configuration
7373

7474
.. best-practice::
7575

76-
Don't use the ``@Template()`` annotation to configure the template used by
76+
Don't use the ``@Template`` annotation to configure the template used by
7777
the controller.
7878

7979
The ``@Template`` annotation is useful, but also involves some magic. We
@@ -148,7 +148,7 @@ For example:
148148
));
149149
}
150150
151-
Normally, you'd expect a ``$id`` argument to ``showAction``. Instead, by
151+
Normally, you'd expect a ``$id`` argument to ``showAction()``. Instead, by
152152
creating a new argument (``$post``) and type-hinting it with the ``Post``
153153
class (which is a Doctrine entity), the ParamConverter automatically queries
154154
for an object whose ``$id`` property matches the ``{id}`` value. It will

best_practices/creating-the-project.rst

+3-5
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ ProductBundle, then there's no advantage to having two separate bundles.
104104

105105
.. best-practice::
106106

107-
Create only one bundle called AppBundle for your application logic
107+
Create only one bundle called AppBundle for your application logic.
108108

109109
Implementing a single AppBundle bundle in your projects will make your code
110110
more concise and easier to understand. Starting in Symfony 2.6, the official
@@ -179,8 +179,6 @@ The changes are pretty superficial, but for now, we recommend that you use
179179
the Symfony directory structure.
180180

181181
.. _`Composer`: https://getcomposer.org/
182-
.. _`Get Started`: https://getcomposer.org/doc/00-intro.md
183-
.. _`Composer download page`: https://getcomposer.org/download/
184-
.. _`public checksums repository`: https://github.com/sensiolabs/checksums
185-
.. _`these steps`: http://fabien.potencier.org/signing-project-releases.html
186182
.. _`Phar extension`: http://php.net/manual/en/intro.phar.php
183+
.. _`public checksums repository`: https://github.com/sensiolabs/checksums
184+
.. _`these steps`: http://fabien.potencier.org/signing-project-releases.html

best_practices/forms.rst

+7-7
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ form in its own PHP class::
5454
Put the form type classes in the ``AppBundle\Form`` namespace, unless you
5555
use other custom form classes like data transformers.
5656

57-
To use the class, use ``createForm`` and instantiate the new class::
57+
To use the class, use ``createForm()`` and instantiate the new class::
5858

5959
// ...
6060
use AppBundle\Form\PostType;
@@ -160,8 +160,8 @@ thing in one line to rendering each part of each field independently. The
160160
best way depends on how much customization you need.
161161

162162
One of the simplest ways - which is especially useful during development -
163-
is to render the form tags and use ``form_widget()`` to render all of the
164-
fields:
163+
is to render the form tags and use the ``form_widget()`` function to render
164+
all of the fields:
165165

166166
.. code-block:: html+twig
167167

@@ -171,7 +171,7 @@ fields:
171171

172172
If you need more control over how your fields are rendered, then you should
173173
remove the ``form_widget(form)`` function and render your fields individually.
174-
See the :doc:`/cookbook/form/form_customization` article for more information
174+
See the :doc:`/cookbook/form/form_customization` cookbook article for more information
175175
on this and how you can control *how* the form renders at a global level
176176
using form theming.
177177

@@ -204,9 +204,9 @@ Handling a form submit usually follows a similar template:
204204
205205
There are really only two notable things here. First, we recommend that you
206206
use a single action for both rendering the form and handling the form submit.
207-
For example, you *could* have a ``newAction`` that *only* renders the form
208-
and a ``createAction`` that *only* processes the form submit. Both those
209-
actions will be almost identical. So it's much simpler to let ``newAction``
207+
For example, you *could* have a ``newAction()`` that *only* renders the form
208+
and a ``createAction()`` that *only* processes the form submit. Both those
209+
actions will be almost identical. So it's much simpler to let ``newAction()``
210210
handle everything.
211211

212212
Second, we recommend using ``$form->isSubmitted()`` in the ``if`` statement

best_practices/i18n.rst

+7-7
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ Translation Source File Location
4747

4848
.. best-practice::
4949

50-
Store the translation files in the ``app/Resources/translations/`` directory.
50+
Store the translation files in the ``app/Resources/translations/``
51+
directory.
5152

5253
Traditionally, Symfony developers have created these files in the
53-
``Resources/translations/`` directory of each bundle.
54-
55-
But since the ``app/Resources/`` directory is considered the global location
56-
for the application's resources, storing translations in ``app/Resources/translations/``
54+
``Resources/translations/`` directory of each bundle. But since the
55+
``app/Resources/`` directory is considered the global location for the
56+
application's resources, storing translations in ``app/Resources/translations/``
5757
centralizes them *and* gives them priority over any other translation file.
58-
This lets you override translations defined in third-party bundles.
58+
This let's you override translations defined in third-party bundles.
5959

6060
Translation Keys
6161
----------------
@@ -85,7 +85,7 @@ English in the application would be:
8585
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
8686
<file source-language="en" target-language="en" datatype="plaintext" original="file.ext">
8787
<body>
88-
<trans-unit id="1">
88+
<trans-unit id="title_post_list">
8989
<source>title.post_list</source>
9090
<target>Post List</target>
9191
</trans-unit>

best_practices/tests.rst

+4-6
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ functional tests, you can quickly spot any big errors before you deploy them:
2626
Define a functional test that at least checks if your application pages
2727
are successfully loading.
2828

29-
A functional test can be as easy as this:
30-
31-
.. code-block:: php
29+
A functional test can be as easy as this::
3230

3331
// src/AppBundle/Tests/ApplicationAvailabilityFunctionalTest.php
3432
namespace AppBundle\Tests;
@@ -116,10 +114,10 @@ Learn More about Functional Tests
116114
Consider using the `HautelookAliceBundle`_ to generate real-looking data for
117115
your test fixtures using `Faker`_ and `Alice`_.
118116

119-
.. _`Faker`: https://github.com/fzaninotto/Faker
120-
.. _`Alice`: https://github.com/nelmio/alice
121117
.. _`PhpUnit`: https://phpunit.de/
122118
.. _`PhpSpec`: http://www.phpspec.net/
123-
.. _`Mink`: http://mink.behat.org
124119
.. _`smoke testing`: https://en.wikipedia.org/wiki/Smoke_testing_(software)
120+
.. _`Mink`: http://mink.behat.org
125121
.. _`HautelookAliceBundle`: https://github.com/hautelook/AliceBundle
122+
.. _`Faker`: https://github.com/fzaninotto/Faker
123+
.. _`Alice`: https://github.com/nelmio/alice

book/translation.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ different formats, XLIFF being the recommended format:
134134
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
135135
<file source-language="en" datatype="plaintext" original="file.ext">
136136
<body>
137-
<trans-unit id="1">
137+
<trans-unit id="symfony_is_great">
138138
<source>Symfony is great</source>
139139
<target>J'aime Symfony</target>
140140
</trans-unit>
@@ -671,7 +671,7 @@ bundle.
671671
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
672672
<file source-language="en" datatype="plaintext" original="file.ext">
673673
<body>
674-
<trans-unit id="1">
674+
<trans-unit id="author.name.not_blank">
675675
<source>author.name.not_blank</source>
676676
<target>Please enter an author name.</target>
677677
</trans-unit>

components/event_dispatcher/introduction.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ answer.
2222
Consider the real-world example where you want to provide a plugin system
2323
for your project. A plugin should be able to add methods, or do something
2424
before or after a method is executed, without interfering with other plugins.
25-
This is not an easy problem to solve with single and multiple inheritance
26-
(were it possible with PHP) has its own drawbacks.
25+
This is not an easy problem to solve with single inheritance, and even if
26+
multiple inheritance was possible with PHP, it comes with its own drawbacks.
2727

2828
The Symfony EventDispatcher component implements the `Mediator`_ pattern
2929
in a simple and effective way to make all these things possible and to make

components/translation/usage.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ recommended format. These files are parsed by one of the loader classes.
115115
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
116116
<file source-language="en" datatype="plaintext" original="file.ext">
117117
<body>
118-
<trans-unit id="1">
118+
<trans-unit id="symfony_is_great">
119119
<source>Symfony is great</source>
120120
<target>J'aime Symfony</target>
121121
</trans-unit>
122-
<trans-unit id="2">
122+
<trans-unit id="symfony.great">
123123
<source>symfony.great</source>
124124
<target>J'aime Symfony</target>
125125
</trans-unit>

cookbook/bundles/extension.rst

+6
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ Other available loaders are the ``YamlFileLoader``, ``PhpFileLoader`` and
113113
The ``IniFileLoader`` can only be used to load parameters and it can only
114114
load them as strings.
115115

116+
.. caution::
117+
118+
If you removed the default file with service definitions (i.e.
119+
``app/config/services.yml``), make sure to also remove it from the
120+
``imports`` key in ``app/config/config.yml``.
121+
116122
Using Configuration to Change the Services
117123
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
118124

cookbook/configuration/environments.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ The new environment is now accessible via::
328328
aren't accessible, the front controller is usually protected from external
329329
IP addresses via the following code at the top of the controller::
330330

331-
if (!in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', 'fe80::1', '::1'))) {
331+
if (!in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1'))) {
332332
die('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
333333
}
334334

cookbook/routing/extra_information.rst

+20-7
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
How to Pass Extra Information from a Route to a Controller
55
==========================================================
66

7-
Parameters inside the ``defaults`` collection don't necessarily have to
8-
match a placeholder in the route ``path``. In fact, you can use the
9-
``defaults`` array to specify extra parameters that will then be accessible as
10-
arguments to your controller:
7+
Parameters inside the ``defaults`` collection don't necessarily have to match
8+
a placeholder in the route ``path``. In fact, you can use the ``defaults``
9+
array to specify extra parameters that will then be accessible as arguments
10+
to your controller, and as attributes of the ``Request`` object:
1111

1212
.. configuration-block::
1313

@@ -52,12 +52,25 @@ arguments to your controller:
5252
5353
return $collection;
5454
55-
Now, you can access this extra parameter in your controller::
55+
Now, you can access this extra parameter in your controller, as an argument
56+
to the controller method::
5657

5758
public function indexAction($page, $title)
5859
{
5960
// ...
6061
}
6162

62-
As you can see, the ``$title`` variable was never defined inside the route path,
63-
but you can still access its value from inside your controller.
63+
Alternatively, the title could be accessed through the ``Request`` object::
64+
65+
use Symfony\Component\HttpFoundation\Request;
66+
67+
public function indexAction(Request $request, $page)
68+
{
69+
$title = $request->attributes->get('title');
70+
71+
// ...
72+
}
73+
74+
As you can see, the ``$title`` variable was never defined inside the route
75+
path, but you can still access its value from inside your controller, through
76+
the method's argument, or from the ``Request`` object's ``attributes`` bag.

cookbook/security/access_control.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ pattern so that it is only accessible by requests from the local server itself:
178178
# ...
179179
access_control:
180180
#
181-
- { path: ^/internal, roles: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, fe80::1, ::1] }
181+
- { path: ^/internal, roles: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] }
182182
- { path: ^/internal, roles: ROLE_NO_ACCESS }
183183
184184
.. code-block:: xml
@@ -195,7 +195,7 @@ pattern so that it is only accessible by requests from the local server itself:
195195
<!-- ... -->
196196
<rule path="^/internal"
197197
role="IS_AUTHENTICATED_ANONYMOUSLY"
198-
ips="127.0.0.1, fe80::1, ::1"
198+
ips="127.0.0.1, ::1"
199199
/>
200200
201201
<rule path="^/internal" role="ROLE_NO_ACCESS" />
@@ -211,7 +211,7 @@ pattern so that it is only accessible by requests from the local server itself:
211211
array(
212212
'path' => '^/internal',
213213
'role' => 'IS_AUTHENTICATED_ANONYMOUSLY',
214-
'ips' => '127.0.0.1, fe80::1, ::1'
214+
'ips' => '127.0.0.1, ::1'
215215
),
216216
array(
217217
'path' => '^/internal',
@@ -232,8 +232,8 @@ the external IP address ``10.0.0.1``:
232232
that does not match an existing role, it just serves as a trick to always
233233
deny access).
234234

235-
But if the same request comes from ``127.0.0.1``, ``::1`` (the IPv6 loopback
236-
address) or ``fe80::1`` (the IPv6 link-local address):
235+
But if the same request comes from ``127.0.0.1`` or ``::1`` (the IPv6 loopback
236+
address):
237237

238238
* Now, the first access control rule is enabled as both the ``path`` and the
239239
``ip`` match: access is allowed as the user always has the

quick_tour/the_architecture.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ Understanding the Cache and Logs
257257
--------------------------------
258258

259259
Symfony applications can contain several configuration files defined in
260-
several formats (YAML, XML, PHP, etc.) Instead of parsing and combining
260+
several formats (YAML, XML, PHP, etc.). Instead of parsing and combining
261261
all those files for each request, Symfony uses its own cache system. In
262262
fact, the application configuration is only parsed for the very first request
263263
and then compiled down to plain PHP code stored in the ``app/cache/``
@@ -309,4 +309,4 @@ need to learn a lot to become a Symfony master. Ready to dig into these
309309
topics now? Look no further - go to the official :doc:`/book/index` and
310310
pick any topic you want.
311311

312-
.. _Composer: https://getcomposer.org
312+
.. _`Composer`: https://getcomposer.org

quick_tour/the_big_picture.rst

+17-14
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,17 @@ When developing a Symfony application, your responsibility as a developer
2929
is to write the code that maps the user's *request* (e.g. ``http://localhost:8000/``)
3030
to the *resource* associated with it (the ``Homepage`` HTML page).
3131

32-
The code to execute is defined in **actions** and **controllers**. The mapping
33-
between user's requests and that code is defined via the **routing** configuration.
34-
And the contents displayed in the browser are usually rendered using **templates**.
32+
The code to execute is defined as methods of PHP classes. The methods are
33+
called **actions** and the classes **controllers**, but in practice most
34+
developers use **controllers** to refer to both of them. The mapping between
35+
user's requests and that code is defined via the **routing** configuration.
36+
And the contents displayed in the browser are usually rendered using
37+
**templates**.
38+
39+
When you go to ``http://localhost:8000/app/example``, Symfony will execute
40+
the controller in ``src/AppBundle/Controller/DefaultController.php`` and
41+
render the ``app/Resources/views/default/index.html.twig`` template.
3542

36-
When you browsed ``http://localhost:8000/app/example`` earlier, Symfony executed
37-
the controller defined in the ``src/AppBundle/Controller/DefaultController.php``
38-
file and rendered the ``app/Resources/views/default/index.html.twig`` template.
3943
In the following sections you'll learn in detail the inner workings of Symfony
4044
controllers, routes and templates.
4145

@@ -69,7 +73,7 @@ is called ``Default`` and the PHP class is called ``DefaultController``.
6973
The methods defined in a controller are called **actions**, they are usually
7074
associated with one URL of the application and their names are suffixed
7175
with ``Action``. In this example, the ``Default`` controller has only one
72-
action called ``index`` and defined in the ``indexAction`` method.
76+
action called ``index`` and defined in the ``indexAction()`` method.
7377

7478
Actions are usually very short - around 10-15 lines of code - because they
7579
just call other parts of the application to get or generate the needed
@@ -85,7 +89,7 @@ Routing
8589
Symfony routes each request to the action that handles it by matching the
8690
requested URL against the paths configured by the application. Open again
8791
the ``src/AppBundle/Controller/DefaultController.php`` file and take a look
88-
at the three lines of code above the ``indexAction`` method::
92+
at the three lines of code above the ``indexAction()`` method::
8993

9094
// src/AppBundle/Controller/DefaultController.php
9195
namespace AppBundle\Controller;
@@ -138,7 +142,8 @@ The only content of the ``index`` action is this PHP instruction::
138142

139143
The ``$this->render()`` method is a convenient shortcut to render a template.
140144
Symfony provides some useful shortcuts to any controller extending from
141-
the ``Controller`` class.
145+
the base Symfony :class:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller`
146+
class.
142147

143148
By default, application templates are stored in the ``app/Resources/views/``
144149
directory. Therefore, the ``default/index.html.twig`` template corresponds
@@ -194,7 +199,7 @@ environments**.
194199
What is an Environment?
195200
~~~~~~~~~~~~~~~~~~~~~~~
196201

197-
An :term:`Environment` represents a group of configurations that's used
202+
An :term:`environment` represents a group of configurations that's used
198203
to run your application. Symfony defines two environments by default: ``dev``
199204
(suited for when developing the application locally) and ``prod`` (optimized
200205
for when executing the application on production).
@@ -235,7 +240,7 @@ In this example, the ``config_dev.yml`` configuration file imports the common
235240
with its own options.
236241

237242
For more details on environments, see
238-
":ref:`Environments & Front Controllers <page-creation-environments>`" article.
243+
:ref:`the "Environments" section <page-creation-environments>` of the book.
239244

240245
Final Thoughts
241246
--------------
@@ -246,6 +251,4 @@ how Symfony makes it really easy to implement web sites better and faster.
246251
If you are eager to learn more about Symfony, dive into the next section:
247252
":doc:`The View <the_view>`".
248253

249-
.. _Composer: https://getcomposer.org/
250-
.. _executable installer: https://getcomposer.org/download
251-
.. _Twig: http://twig.sensiolabs.org/
254+
.. _`Twig`: http://twig.sensiolabs.org/

0 commit comments

Comments
 (0)