Skip to content

Commit 39dfbe5

Browse files
committed
Merge branch '3.1'
2 parents 3fe2f1d + 14d4ee6 commit 39dfbe5

File tree

14 files changed

+89
-197
lines changed

14 files changed

+89
-197
lines changed

best_practices/business-logic.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ the class namespace as a parameter:
151151
app.slugger:
152152
class: '%slugger.class%'
153153
154-
This practice is cumbersome and completely unnecessary for your own services:
154+
This practice is cumbersome and completely unnecessary for your own services.
155155

156156
.. best-practice::
157157

book/forms.rst

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ In :ref:`book-form-creating-form-classes` you will learn how to move the
992992
form building code into separate classes. When using an external form class
993993
in the controller, you can pass the action and method as form options::
994994

995-
use AppBundle\Form\Type\TaskType;
995+
use AppBundle\Form\TaskType;
996996
// ...
997997

998998
$form = $this->createForm(TaskType::class, $task, array(
@@ -1040,8 +1040,8 @@ However, a better practice is to build the form in a separate, standalone PHP
10401040
class, which can then be reused anywhere in your application. Create a new class
10411041
that will house the logic for building the task form::
10421042

1043-
// src/AppBundle/Form/Type/TaskType.php
1044-
namespace AppBundle\Form\Type;
1043+
// src/AppBundle/Form/TaskType.php
1044+
namespace AppBundle\Form;
10451045

10461046
use Symfony\Component\Form\AbstractType;
10471047
use Symfony\Component\Form\FormBuilderInterface;
@@ -1063,7 +1063,7 @@ This new class contains all the directions needed to create the task form. It ca
10631063
be used to quickly build a form object in the controller::
10641064

10651065
// src/AppBundle/Controller/DefaultController.php
1066-
use AppBundle\Form\Type\TaskType;
1066+
use AppBundle\Form\TaskType;
10671067

10681068
public function newAction()
10691069
{
@@ -1184,7 +1184,7 @@ Define your form type as a service.
11841184
# src/AppBundle/Resources/config/services.yml
11851185
services:
11861186
app.form.type.task:
1187-
class: AppBundle\Form\Type\TaskType
1187+
class: AppBundle\Form\TaskType
11881188
arguments: ["@app.my_service"]
11891189
tags:
11901190
- { name: form.type }
@@ -1198,7 +1198,7 @@ Define your form type as a service.
11981198
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
11991199
12001200
<services>
1201-
<service id="app.form.type.task" class="AppBundle\Form\Type\TaskType">
1201+
<service id="app.form.type.task" class="AppBundle\Form\TaskType">
12021202
<tag name="form.type" />
12031203
<argument type="service" id="app.my_service"></argument>
12041204
</service>
@@ -1210,7 +1210,7 @@ Define your form type as a service.
12101210
// src/AppBundle/Resources/config/services.php
12111211
use Symfony\Component\DependencyInjection\Reference;
12121212
1213-
$container->register('app.form.type.task', 'AppBundle\Form\Type\TaskType')
1213+
$container->register('app.form.type.task', 'AppBundle\Form\TaskType')
12141214
->addArgument(new Reference('app.my_service'))
12151215
->addTag('form.type')
12161216
@@ -1318,8 +1318,8 @@ Next, add a new ``category`` property to the ``Task`` class::
13181318
Now that your application has been updated to reflect the new requirements,
13191319
create a form class so that a ``Category`` object can be modified by the user::
13201320

1321-
// src/AppBundle/Form/Type/CategoryType.php
1322-
namespace AppBundle\Form\Type;
1321+
// src/AppBundle/Form/CategoryType.php
1322+
namespace AppBundle\Form;
13231323

13241324
use Symfony\Component\Form\AbstractType;
13251325
use Symfony\Component\Form\FormBuilderInterface;
@@ -1343,12 +1343,10 @@ create a form class so that a ``Category`` object can be modified by the user::
13431343
The end goal is to allow the ``Category`` of a ``Task`` to be modified right
13441344
inside the task form itself. To accomplish this, add a ``category`` field
13451345
to the ``TaskType`` object whose type is an instance of the new ``CategoryType``
1346-
class:
1347-
1348-
.. code-block:: php
1346+
class::
13491347

13501348
use Symfony\Component\Form\FormBuilderInterface;
1351-
use AppBundle\Form\Type\CategoryType;
1349+
use AppBundle\Form\CategoryType;
13521350

13531351
public function buildForm(FormBuilderInterface $builder, array $options)
13541352
{

book/from_flat_php_to_symfony2.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ is primarily an HTML file that uses a template-like PHP syntax:
123123
</html>
124124

125125
By convention, the file that contains all the application logic - ``index.php`` -
126-
is known as a "controller". The term :term:`controller` is a word you'll hear
127-
a lot, regardless of the language or framework you use. It refers simply
128-
to the area of *your* code that processes user input and prepares the response.
126+
is known as a "controller". The term controller is a word you'll hear a lot,
127+
regardless of the language or framework you use. It refers simply to the area
128+
of *your* code that processes user input and prepares the response.
129129

130130
In this case, the controller prepares data from the database and then includes
131131
a template to present that data. With the controller isolated, you could
@@ -312,8 +312,8 @@ to security...
312312
A "Front Controller" to the Rescue
313313
----------------------------------
314314

315-
The solution is to use a :term:`front controller`: a single PHP file through
316-
which *all* requests are processed. With a front controller, the URIs for the
315+
The solution is to use a front controller: a single PHP file through which
316+
*all* requests are processed. With a front controller, the URIs for the
317317
application change slightly, but start to become more flexible:
318318

319319
.. code-block:: text

book/http_cache.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ websites, or is it? In this chapter, you'll see how the Symfony cache
2626
system works and why this is the best possible approach.
2727

2828
The Symfony cache system is different because it relies on the simplicity
29-
and power of the HTTP cache as defined in the :term:`HTTP specification`.
30-
Instead of reinventing a caching methodology, Symfony embraces the standard
31-
that defines basic communication on the Web. Once you understand the fundamental
32-
HTTP validation and expiration caching models, you'll be ready to master
33-
the Symfony cache system.
29+
and power of the HTTP cache as defined in the `HTTP specification`_. Instead of
30+
reinventing a caching methodology, Symfony embraces the standard that defines
31+
basic communication on the Web. Once you understand the fundamental HTTP
32+
validation and expiration caching models, you'll be ready to master the Symfony
33+
cache system.
3434

3535
For the purposes of learning how to cache with Symfony, the
3636
subject is covered in four steps:
@@ -1251,3 +1251,4 @@ Learn more from the Cookbook
12511251
.. _`FrameworkExtraBundle documentation`: https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/cache.html
12521252
.. _`ESI`: http://www.w3.org/TR/esi-lang
12531253
.. _`FOSHttpCacheBundle`: http://foshttpcachebundle.readthedocs.org/
1254+
.. _`HTTP specification`: http://www.w3.org/Protocols/rfc2616/rfc2616.html

book/http_fundamentals.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,8 @@ breaking all of your links?) and the fact that each file *must* manually
334334
include some set of core files so that security, database connections and
335335
the "look" of the site can remain consistent.
336336

337-
A much better solution is to use a :term:`front controller`: a single PHP
338-
file that handles every request coming into your application. For example:
337+
A much better solution is to use a front controller: a single PHP file that
338+
handles every request coming into your application. For example:
339339

340340
+------------------------+------------------------+
341341
| ``/index.php`` | executes ``index.php`` |
@@ -401,8 +401,8 @@ the same simple pattern for every request:
401401

402402
Each "page" of your site is defined in a routing configuration file that
403403
maps different URLs to different PHP functions. The job of each PHP function,
404-
called a :term:`controller`, is to use information from the request - along
405-
with many other tools Symfony makes available - to create and return a ``Response``
404+
called a controller, is to use information from the request - along with many
405+
other tools Symfony makes available - to create and return a ``Response``
406406
object. In other words, the controller is where *your* code goes: it's where
407407
you interpret the request and create a response.
408408

book/routing.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,6 +1550,30 @@ a template helper function:
15501550
Read this blog post.
15511551
</a>
15521552

1553+
.. tip::
1554+
1555+
If you are generating the route inside a ``<script>`` element, it's a good
1556+
practice to escape it for JavaScript:
1557+
1558+
.. configuration-block::
1559+
1560+
.. code-block:: html+twig
1561+
1562+
<script>
1563+
var route = "{{ path('blog_show', {'slug': 'my-blog-post'})|escape('js') }}";
1564+
</script>
1565+
1566+
.. code-block:: html+php
1567+
1568+
<script>
1569+
var route = "<?php echo $view->escape(
1570+
$view['router']->path('blow_show', array(
1571+
'slug' => 'my-blog-post',
1572+
)),
1573+
'js'
1574+
) ?>";
1575+
</script>
1576+
15531577
.. index::
15541578
single: Routing; Absolute URLs
15551579

book/service_container.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ the service container makes writing good code so easy.
3939
What is a Service?
4040
------------------
4141

42-
Put simply, a :term:`Service` is any PHP object that performs some sort of
43-
"global" task. It's a purposefully-generic name used in computer science
44-
to describe an object that's created for a specific purpose (e.g. delivering
45-
emails). Each service is used throughout your application whenever you need
46-
the specific functionality it provides. You don't have to do anything special
47-
to make a service: simply write a PHP class with some code that accomplishes
48-
a specific task. Congratulations, you've just created a service!
42+
Put simply, a service is any PHP object that performs some sort of "global"
43+
task. It's a purposefully-generic name used in computer science to describe an
44+
object that's created for a specific purpose (e.g. delivering emails). Each
45+
service is used throughout your application whenever you need the specific
46+
functionality it provides. You don't have to do anything special to make a
47+
service: simply write a PHP class with some code that accomplishes a specific
48+
task. Congratulations, you've just created a service!
4949

5050
.. note::
5151

@@ -72,8 +72,8 @@ are key to being a good developer in almost any language.
7272
What is a Service Container?
7373
----------------------------
7474

75-
A :term:`Service Container` (or *dependency injection container*) is simply
76-
a PHP object that manages the instantiation of services (i.e. objects).
75+
A service container (or *dependency injection container*) is simply a PHP
76+
object that manages the instantiation of services (i.e. objects).
7777

7878
For example, suppose you have a simple PHP class that delivers email messages.
7979
Without a service container, you must manually create the object whenever

book/translation.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ to learn even more. Overall, the process has several steps:
5151
Configuration
5252
-------------
5353

54-
Translations are handled by a ``translator`` :term:`service` that uses the
55-
user's locale to lookup and return translated messages. Before using it,
56-
enable the ``translator`` in your configuration:
54+
Translations are handled by a ``translator`` service that uses the user's
55+
locale to lookup and return translated messages. Before using it, enable the
56+
``translator`` in your configuration:
5757

5858
.. configuration-block::
5959

components/form/introduction.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,12 @@ and then access it whenever you need to build a form.
359359
this object in some more "global" way so you can access it from anywhere.
360360

361361
Exactly how you gain access to your one form factory is up to you. If you're
362-
using a :term:`Service Container`, then you should add the form factory to
363-
your container and grab it out whenever you need to. If your application
364-
uses global or static variables (not usually a good idea), then you can store
365-
the object on some static class or do something similar.
362+
using a service container (like provided with the
363+
:doc:`DependencyInjection component </components/dependency_injection/introduction>`),
364+
then you should add the form factory to your container and grab it out whenever
365+
you need to. If your application uses global or static variables (not usually a
366+
good idea), then you can store the object on some static class or do something
367+
similar.
366368

367369
Regardless of how you architect your application, just remember that you
368370
should only have one form factory and that you'll need to be able to access

cookbook/email/email.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,19 @@ can modify the values in that file, or set the values directly here.
7272

7373
The following configuration attributes are available:
7474

75-
* ``transport`` (``smtp``, ``mail``, ``sendmail``, or ``gmail``)
75+
* ``transport`` (``smtp``, ``mail``, ``sendmail``, or ``gmail``)
7676
* ``username``
7777
* ``password``
7878
* ``host``
7979
* ``port``
80-
* ``encryption`` (``tls``, or ``ssl``)
81-
* ``auth_mode`` (``plain``, ``login``, or ``cram-md5``)
80+
* ``encryption`` (``tls``, or ``ssl``)
81+
* ``auth_mode`` (``plain``, ``login``, or ``cram-md5``)
8282
* ``spool``
8383

8484
* ``type`` (how to queue the messages, ``file`` or ``memory`` is supported, see :doc:`/cookbook/email/spool`)
8585
* ``path`` (where to store the messages)
86-
* ``delivery_address`` (an email address where to send ALL emails)
87-
* ``disable_delivery`` (set to true to disable delivery completely)
86+
* ``delivery_address`` (an email address where to send ALL emails)
87+
* ``disable_delivery`` (set to true to disable delivery completely)
8888

8989
Sending Emails
9090
--------------
@@ -133,6 +133,8 @@ template might look something like this:
133133
{# app/Resources/views/Emails/registration.html.twig #}
134134
<h3>You did it! You registered!</h3>
135135

136+
Hi {{ name }}! You're successfully registered.
137+
136138
{# example, assuming you have a route named "login" #}
137139
To login, go to: <a href="{{ url('login') }}">...</a>.
138140

0 commit comments

Comments
 (0)