Skip to content

Commit f40bb61

Browse files
committed
Merge branch '2.7' into 2.8
Conflicts: book/forms.rst book/routing.rst
2 parents 679ac48 + 70c980d commit f40bb61

File tree

15 files changed

+89
-202
lines changed

15 files changed

+89
-202
lines changed

best_practices/business-logic.rst

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

152152
.. best-practice::
153153

book/forms.rst

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

1027-
use AppBundle\Form\Type\TaskType;
1027+
use AppBundle\Form\TaskType;
10281028
// ...
10291029

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

1077-
// src/AppBundle/Form/Type/TaskType.php
1078-
namespace AppBundle\Form\Type;
1077+
// src/AppBundle/Form/TaskType.php
1078+
namespace AppBundle\Form;
10791079

10801080
use Symfony\Component\Form\AbstractType;
10811081
use Symfony\Component\Form\FormBuilderInterface;
@@ -1097,7 +1097,7 @@ This new class contains all the directions needed to create the task form. It ca
10971097
be used to quickly build a form object in the controller::
10981098

10991099
// src/AppBundle/Controller/DefaultController.php
1100-
use AppBundle\Form\Type\TaskType;
1100+
use AppBundle\Form\TaskType;
11011101

11021102
public function newAction()
11031103
{
@@ -1218,7 +1218,7 @@ Define your form type as a service.
12181218
# src/AppBundle/Resources/config/services.yml
12191219
services:
12201220
app.form.type.task:
1221-
class: AppBundle\Form\Type\TaskType
1221+
class: AppBundle\Form\TaskType
12221222
arguments: ["@app.my_service"]
12231223
tags:
12241224
- { name: form.type }
@@ -1232,7 +1232,7 @@ Define your form type as a service.
12321232
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
12331233
12341234
<services>
1235-
<service id="app.form.type.task" class="AppBundle\Form\Type\TaskType">
1235+
<service id="app.form.type.task" class="AppBundle\Form\TaskType">
12361236
<tag name="form.type" />
12371237
<argument type="service" id="app.my_service"></argument>
12381238
</service>
@@ -1244,7 +1244,7 @@ Define your form type as a service.
12441244
// src/AppBundle/Resources/config/services.php
12451245
use Symfony\Component\DependencyInjection\Reference;
12461246
1247-
$container->register('app.form.type.task', 'AppBundle\Form\Type\TaskType')
1247+
$container->register('app.form.type.task', 'AppBundle\Form\TaskType')
12481248
->addArgument(new Reference('app.my_service'))
12491249
->addTag('form.type')
12501250
@@ -1352,8 +1352,8 @@ Next, add a new ``category`` property to the ``Task`` class::
13521352
Now that your application has been updated to reflect the new requirements,
13531353
create a form class so that a ``Category`` object can be modified by the user::
13541354

1355-
// src/AppBundle/Form/Type/CategoryType.php
1356-
namespace AppBundle\Form\Type;
1355+
// src/AppBundle/Form/CategoryType.php
1356+
namespace AppBundle\Form;
13571357

13581358
use Symfony\Component\Form\AbstractType;
13591359
use Symfony\Component\Form\FormBuilderInterface;
@@ -1377,12 +1377,10 @@ create a form class so that a ``Category`` object can be modified by the user::
13771377
The end goal is to allow the ``Category`` of a ``Task`` to be modified right
13781378
inside the task form itself. To accomplish this, add a ``category`` field
13791379
to the ``TaskType`` object whose type is an instance of the new ``CategoryType``
1380-
class:
1381-
1382-
.. code-block:: php
1380+
class::
13831381

13841382
use Symfony\Component\Form\FormBuilderInterface;
1385-
use AppBundle\Form\Type\CategoryType;
1383+
use AppBundle\Form\CategoryType;
13861384

13871385
public function buildForm(FormBuilderInterface $builder, array $options)
13881386
{

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:
@@ -1259,3 +1259,4 @@ Learn more from the Cookbook
12591259
.. _`FrameworkExtraBundle documentation`: https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/cache.html
12601260
.. _`ESI`: http://www.w3.org/TR/esi-lang
12611261
.. _`FOSHttpCacheBundle`: http://foshttpcachebundle.readthedocs.org/
1262+
.. _`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
@@ -1554,6 +1554,30 @@ a template helper function:
15541554
The ``path()`` PHP templating helper was introduced in Symfony 2.8. Prior
15551555
to 2.8, you had to use the ``generate()`` helper method.
15561556

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

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
@@ -362,10 +362,12 @@ and then access it whenever you need to build a form.
362362
this object in some more "global" way so you can access it from anywhere.
363363

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

370372
Regardless of how you architect your application, just remember that you
371373
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

cookbook/symfony1.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,6 @@ Of course, there's nothing wrong with having multiple applications in your
218218
project, that's entirely up to you. A second application would mean a new
219219
directory, e.g. ``my_app/``, with the same basic setup as the ``app/`` directory.
220220

221-
.. tip::
222-
223-
Read the definition of a :term:`Project`, an :term:`Application`, and a
224-
:term:`Bundle` in the glossary.
225-
226221
Bundles and Plugins
227222
-------------------
228223

0 commit comments

Comments
 (0)