Skip to content

Commit f24b8f8

Browse files
committed
Merge branch '2.8' into 3.0
* 2.8: [#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 Rename DunglasApiBundle to ApiPlatform
2 parents 2e03a7e + e87e9ee commit f24b8f8

20 files changed

+114
-89
lines changed

best_practices/business-logic.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ The three entities defined by our sample blog application are a good example:
197197
Doctrine Mapping Information
198198
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
199199

200-
Doctrine Entities are plain PHP objects that you store in some "database".
200+
Doctrine entities are plain PHP objects that you store in some "database".
201201
Doctrine only knows about your entities through the mapping metadata configured
202202
for your model classes. Doctrine supports four metadata formats: YAML, XML,
203203
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
@@ -111,7 +111,7 @@ ProductBundle, then there's no advantage to having two separate bundles.
111111

112112
.. best-practice::
113113

114-
Create only one bundle called AppBundle for your application logic
114+
Create only one bundle called AppBundle for your application logic.
115115

116116
Implementing a single AppBundle bundle in your projects will make your code
117117
more concise and easier to understand.
@@ -169,8 +169,6 @@ structure of Symfony, you can
169169
``cache/``, ``logs/`` and ``web/``.
170170

171171
.. _`Composer`: https://getcomposer.org/
172-
.. _`Get Started`: https://getcomposer.org/doc/00-intro.md
173-
.. _`Composer download page`: https://getcomposer.org/download/
174-
.. _`public checksums repository`: https://github.com./sensiolabs/checksums
175-
.. _`these steps`: http://fabien.potencier.org/signing-project-releases.html
176172
.. _`Phar extension`: http://php.net/manual/en/intro.phar.php
173+
.. _`public checksums repository`: https://github.com./sensiolabs/checksums
174+
.. _`these steps`: http://fabien.potencier.org/signing-project-releases.html

best_practices/forms.rst

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

55-
To use the class, use ``createForm`` and pass the fully qualified class name::
55+
To use the class, use ``createForm()`` and pass the fully qualified class name::
5656

5757
// ...
5858
use AppBundle\Form\PostType;
@@ -156,8 +156,8 @@ thing in one line to rendering each part of each field independently. The
156156
best way depends on how much customization you need.
157157

158158
One of the simplest ways - which is especially useful during development -
159-
is to render the form tags and use ``form_widget()`` to render all of the
160-
fields:
159+
is to render the form tags and use the ``form_widget()`` function to render
160+
all of the fields:
161161

162162
.. code-block:: html+twig
163163

@@ -167,7 +167,7 @@ fields:
167167

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

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

208208
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
// tests/AppBundle/ApplicationAvailabilityFunctionalTest.php
3432
namespace Tests\AppBundle;
@@ -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>
@@ -713,7 +713,7 @@ bundle.
713713
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
714714
<file source-language="en" datatype="plaintext" original="file.ext">
715715
<body>
716-
<trans-unit id="1">
716+
<trans-unit id="author.name.not_blank">
717717
<source>author.name.not_blank</source>
718718
<target>Please enter an author name.</target>
719719
</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
@@ -324,7 +324,7 @@ The new environment is now accessible via::
324324
aren't accessible, the front controller is usually protected from external
325325
IP addresses via the following code at the top of the controller::
326326

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

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

cookbook/serializer.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ A service leveraging `APCu`_ (and APC for PHP < 5.5) is built-in.
202202
Going Further with the Serializer Component
203203
-------------------------------------------
204204

205-
`DunglasApiBundle`_ provides an API system supporting `JSON-LD`_ and `Hydra Core Vocabulary`_
205+
`ApiPlatform`_ provides an API system supporting `JSON-LD`_ and `Hydra Core Vocabulary`_
206206
hypermedia formats. It is built on top of the Symfony Framework and its Serializer
207207
component. It provides custom normalizers and a custom encoder, custom metadata
208208
and a caching system.
@@ -211,6 +211,6 @@ If you want to leverage the full power of the Symfony Serializer component,
211211
take a look at how this bundle works.
212212

213213
.. _`APCu`: https://github.com./krakjoe/apcu
214-
.. _`DunglasApiBundle`: https://github.com./dunglas/DunglasApiBundle
214+
.. _`ApiPlatform`: https://github.com./api-platform/core
215215
.. _`JSON-LD`: http://json-ld.org
216216
.. _`Hydra Core Vocabulary`: http://hydra-cg.com

quick_tour/the_architecture.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ Understanding the Cache and Logs
263263
--------------------------------
264264

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

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

0 commit comments

Comments
 (0)