Skip to content

Commit af97ce1

Browse files
committed
Merge branch '2.8'
2 parents 267e898 + 5a361ee commit af97ce1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+591
-205
lines changed

book/doctrine.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -534,10 +534,10 @@ Take a look at the previous example in more detail:
534534
responsible for handling the process of persisting and fetching objects
535535
to and from the database.
536536

537-
* **line 16** The ``persist()`` method tells Doctrine to "manage" the ``$product``
537+
* **line 17** The ``persist()`` method tells Doctrine to "manage" the ``$product``
538538
object. This does not actually cause a query to be made to the database (yet).
539539

540-
* **line 17** When the ``flush()`` method is called, Doctrine looks through
540+
* **line 18** When the ``flush()`` method is called, Doctrine looks through
541541
all of the objects that it's managing to see if they need to be persisted
542542
to the database. In this example, the ``$product`` object has not been
543543
persisted yet, so the entity manager executes an ``INSERT`` query and a

book/routing.rst

+7-18
Original file line numberDiff line numberDiff line change
@@ -1473,25 +1473,14 @@ route. With this information, any URL can easily be generated::
14731473

14741474
.. note::
14751475

1476-
In controllers that don't extend Symfony's base
1477-
:class:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller`,
1478-
you can use the ``router`` service's
1479-
:method:`Symfony\\Component\\Routing\\Router::generate` method::
1476+
The ``generateUrl()`` method defined in the base
1477+
:class:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller` class is
1478+
just a shortcut for this code::
14801479

1481-
use Symfony\Component\DependencyInjection\ContainerAware;
1482-
1483-
class MainController extends ContainerAware
1484-
{
1485-
public function showAction($slug)
1486-
{
1487-
// ...
1488-
1489-
$url = $this->container->get('router')->generate(
1490-
'blog_show',
1491-
array('slug' => 'my-blog-post')
1492-
);
1493-
}
1494-
}
1480+
$url = $this->container->get('router')->generate(
1481+
'blog_show',
1482+
array('slug' => 'my-blog-post')
1483+
);
14951484

14961485
In an upcoming section, you'll learn how to generate URLs from inside templates.
14971486

book/security.rst

+7-9
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ Access Control in Templates
884884
...........................
885885

886886
If you want to check if the current user has a role inside a template, use
887-
the built-in helper function:
887+
the built-in ``is_granted()`` helper function:
888888

889889
.. configuration-block::
890890

@@ -900,20 +900,18 @@ the built-in helper function:
900900
<a href="...">Delete</a>
901901
<?php endif ?>
902902

903-
If you use this function and you are *not* behind a firewall, an exception will
904-
be thrown. Again, it's almost always a good idea to have a main firewall that
905-
covers all URLs (as shown before in this chapter).
906-
907-
.. caution::
903+
.. note::
908904

909-
Be careful with this in your base layout or on your error pages! Because of
910-
some internal Symfony details, to avoid broken error pages in the ``prod``
911-
environment, wrap calls in these templates with a check for ``app.user``:
905+
In Symfony versions previous to 2.8, using the ``is_granted()`` function
906+
in a page that wasn't behind a firewall resulted in an exception. That's why
907+
you also needed to check first for the existence of the user:
912908

913909
.. code-block:: html+twig
914910

915911
{% if app.user and is_granted('ROLE_ADMIN') %}
916912

913+
Starting from Symfony 2.8, the ``app.user and ...`` check is no longer needed.
914+
917915
Securing other Services
918916
.......................
919917

book/service_container.rst

+12-10
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,10 @@ The service container is built using a single configuration resource
276276
be imported from inside this file in one way or another. This gives you absolute
277277
flexibility over the services in your application.
278278

279-
External service configuration can be imported in two different ways. The first
280-
method, commonly used to import container configuration from the bundles you've
281-
created - is via the ``imports`` directive. The second method, although slightly more
282-
complex offers more flexibility and is commonly used to import third-party bundle
279+
External service configuration can be imported in two different ways. The first
280+
method, commonly used to import container configuration from the bundles you've
281+
created - is via the ``imports`` directive. The second method, although slightly more
282+
complex offers more flexibility and is commonly used to import third-party bundle
283283
configuration. Read on to learn more about both methods.
284284

285285
.. index::
@@ -1104,13 +1104,15 @@ to be used for a specific purpose. Take the following example:
11041104
xsi:schemaLocation="http://symfony.com/schema/dic/services
11051105
http://symfony.com/schema/dic/services/services-1.0.xsd">
11061106
1107-
<service
1108-
id="foo.twig.extension"
1109-
class="Acme\HelloBundle\Extension\FooExtension"
1110-
public="false">
1107+
<services>
1108+
<service
1109+
id="foo.twig.extension"
1110+
class="Acme\HelloBundle\Extension\FooExtension"
1111+
public="false">
11111112
1112-
<tag name="twig.extension" />
1113-
</service>
1113+
<tag name="twig.extension" />
1114+
</service>
1115+
</services>
11141116
</container>
11151117
11161118
.. code-block:: php

book/templating.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,7 @@ if you are using Twig (or the third argument if you are using PHP) to ``true``:
10981098

10991099
.. code-block:: html+jinja
11001100

1101-
<img src="{{ asset('images/logo.png', absolute=true) }}" alt="Symfony!" />
1101+
<img src="{{ absolute_url(asset('images/logo.png')) }}" alt="Symfony!" />
11021102

11031103
.. code-block:: html+php
11041104

components/console/helpers/debug_formatter.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ Stopping a Program
117117
------------------
118118

119119
When a program is stopped, you can use
120-
:method:`Symfony\\Component\\Console\\Helper\\DebugFormatterHelper::run` to
120+
:method:`Symfony\\Component\\Console\\Helper\\DebugFormatterHelper::stop` to
121121
notify this to the users::
122122

123123
// ...

components/console/helpers/table.rst

+91
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,94 @@ Here is a full list of things you can customize:
143143
$table->setStyle('colorful');
144144

145145
This method can also be used to override a built-in style.
146+
147+
Spanning Multiple Columns and Rows
148+
----------------------------------
149+
150+
.. versionadded:: 2.7
151+
Spanning multiple columns and rows was introduced in Symfony 2.7.
152+
153+
To make a table cell that spans multiple columns you can use a :class:`Symfony\\Component\\Console\\Helper\\TableCell`::
154+
155+
use Symfony\Component\Console\Helper\Table;
156+
use Symfony\Component\Console\Helper\TableSeparator;
157+
use Symfony\Component\Console\Helper\TableCell;
158+
159+
$table = new Table($output);
160+
$table
161+
->setHeaders(array('ISBN', 'Title', 'Author'))
162+
->setRows(array(
163+
array('99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'),
164+
new TableSeparator(),
165+
array(new TableCell('This value spans 3 columns.', array('colspan' => 3))),
166+
))
167+
;
168+
$table->render();
169+
170+
This results in:
171+
172+
.. code-block:: text
173+
174+
+---------------+---------------+-----------------+
175+
| ISBN | Title | Author |
176+
+---------------+---------------+-----------------+
177+
| 99921-58-10-7 | Divine Comedy | Dante Alighieri |
178+
+---------------+---------------+-----------------+
179+
| This value spans 3 columns. |
180+
+---------------+---------------+-----------------+
181+
182+
.. tip::
183+
184+
You can create a multiple-line page title using a header cell that spans
185+
the enire table width::
186+
187+
$table->setHeaders(array(
188+
array(new TableCell('Main table title', array('colspan' => 3))),
189+
array('ISBN', 'Title', 'Author'),
190+
))
191+
// ...
192+
193+
This generates:
194+
195+
.. code-block:: text
196+
197+
+-------+-------+--------+
198+
| Main table title |
199+
+-------+-------+--------+
200+
| ISBN | Title | Author |
201+
+-------+-------+--------+
202+
| ... |
203+
+-------+-------+--------+
204+
205+
In a similar way you can span multiple rows::
206+
207+
use Symfony\Component\Console\Helper\Table;
208+
use Symfony\Component\Console\Helper\TableCell;
209+
210+
$table = new Table($output);
211+
$table
212+
->setHeaders(array('ISBN', 'Title', 'Author'))
213+
->setRows(array(
214+
array(
215+
'978-0521567817',
216+
'De Monarchia',
217+
new TableCell("Dante Alighieri\nspans multiple rows", array('rowspan' => 2)),
218+
),
219+
array('978-0804169127', 'Divine Comedy'),
220+
))
221+
;
222+
$table->render();
223+
224+
This outputs:
225+
226+
.. code-block:: text
227+
228+
+----------------+---------------+---------------------+
229+
| ISBN | Title | Author |
230+
+----------------+---------------+---------------------+
231+
| 978-0521567817 | De Monarchia | Dante Alighieri |
232+
| 978-0804169127 | Divine Comedy | spans multiple rows |
233+
+----------------+---------------+---------------------+
234+
235+
You can use the ``colspan`` and ``rowspan`` options at the same time which allows
236+
you to create any table layout you may wish.

contributing/code/security.rst

+2
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ Security Advisories
103103
This section indexes security vulnerabilities that were fixed in Symfony
104104
releases, starting from Symfony 1.0.0:
105105

106+
* November 23, 2015: `CVE-2015-8125: Potential Remote Timing Attack Vulnerability in Security Remember-Me Service <http://symfony.com/blog/cve-2015-8125-potential-remote-timing-attack-vulnerability-in-security-remember-me-service>`_ (2.3.35, 2.6.12 and 2.7.7)
107+
* November 23, 2015: `CVE-2015-8124: Session Fixation in the "Remember Me" Login Feature <http://symfony.com/blog/cve-2015-8124-session-fixation-in-the-remember-me-login-feature>`_ (2.3.35, 2.6.12 and 2.7.7)
106108
* May 26, 2015: `CVE-2015-4050: ESI unauthorized access <https://symfony.com/blog/cve-2015-4050-esi-unauthorized-access>`_ (Symfony 2.3.29, 2.5.12 and 2.6.8)
107109
* April 1, 2015: `CVE-2015-2309: Unsafe methods in the Request class <https://symfony.com/blog/cve-2015-2309-unsafe-methods-in-the-request-class>`_ (Symfony 2.3.27, 2.5.11 and 2.6.6)
108110
* April 1, 2015: `CVE-2015-2308: Esi Code Injection <https://symfony.com/blog/cve-2015-2308-esi-code-injection>`_ (Symfony 2.3.27, 2.5.11 and 2.6.6)

cookbook/configuration/override_dir_structure.rst

+1-2
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,7 @@ The change in the ``composer.json`` will look like this:
176176
...
177177
}
178178
179-
In ``app/autoload.php``, you need to modify the path leading to the
180-
``vendor/autoload.php`` file::
179+
Then, update the path to the ``autoload.php`` file in ``app/autoload.php``::
181180

182181
// app/autoload.php
183182
// ...

cookbook/controller/error_pages.rst

+1-19
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ To override the 404 error template for HTML pages, create a new
9696
<h1>Page not found</h1>
9797

9898
{# example security usage, see below #}
99-
{% if app.user and is_granted('IS_AUTHENTICATED_FULLY') %}
99+
{% if is_granted('IS_AUTHENTICATED_FULLY') %}
100100
{# ... #}
101101
{% endif %}
102102

@@ -124,24 +124,6 @@ store the HTTP status code and message respectively.
124124
for the standard HTML exception page or ``exception.json.twig`` for the JSON
125125
exception page.
126126

127-
Avoiding Exceptions when Using Security Functions in Error Templates
128-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
129-
130-
One of the common pitfalls when designing custom error pages is to use the
131-
``is_granted()`` function in the error template (or in any parent template
132-
inherited by the error template). If you do that, you'll see an exception thrown
133-
by Symfony.
134-
135-
The cause of this problem is that routing is done before security. If a 404 error
136-
occurs, the security layer isn't loaded and thus, the ``is_granted()`` function
137-
is undefined. The solution is to add the following check before using this function:
138-
139-
.. code-block:: twig
140-
141-
{% if app.user and is_granted('...') %}
142-
{# ... #}
143-
{% endif %}
144-
145127
.. _testing-error-pages:
146128

147129
Testing Error Pages during Development

cookbook/doctrine/event_listeners_subscribers.rst

+7-5
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,14 @@ a ``postPersist`` method, which will be called when the event is dispatched::
135135
public function postPersist(LifecycleEventArgs $args)
136136
{
137137
$entity = $args->getEntity();
138-
$entityManager = $args->getEntityManager();
139138

140-
// perhaps you only want to act on some "Product" entity
141-
if ($entity instanceof Product) {
142-
// ... do something with the Product
139+
// only act on some "Product" entity
140+
if (!$entity instanceof Product) {
141+
return;
143142
}
143+
144+
$entityManager = $args->getEntityManager();
145+
// ... do something with the Product
144146
}
145147
}
146148

@@ -197,10 +199,10 @@ interface and have an event method for each event it subscribes to::
197199
public function index(LifecycleEventArgs $args)
198200
{
199201
$entity = $args->getEntity();
200-
$entityManager = $args->getEntityManager();
201202

202203
// perhaps you only want to act on some "Product" entity
203204
if ($entity instanceof Product) {
205+
$entityManager = $args->getEntityManager();
204206
// ... do something with the Product
205207
}
206208
}

cookbook/form/dynamic_form_modification.rst

+10-9
Original file line numberDiff line numberDiff line change
@@ -411,25 +411,26 @@ it with :ref:`dic-tags-form-type`.
411411
array('security.token_storage')
412412
);
413413
414-
If you wish to create it from within a controller or any other service that has
415-
access to the form factory, you then use::
414+
If you wish to create it from within a service that has access to the form factory,
415+
you then use::
416416

417-
use Symfony\Component\DependencyInjection\ContainerAware;
417+
$form = $formFactory->create('friend_message');
418418

419-
class FriendMessageController extends ContainerAware
419+
In a controller that extends the :class:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller`
420+
class, you can simply call::
421+
422+
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
423+
424+
class FriendMessageController extends Controller
420425
{
421426
public function newAction(Request $request)
422427
{
423-
$form = $this->get('form.factory')->create('friend_message');
428+
$form = $this->createForm('friend_message');
424429

425430
// ...
426431
}
427432
}
428433

429-
If you extend the ``Symfony\Bundle\FrameworkBundle\Controller\Controller`` class, you can simply call::
430-
431-
$form = $this->createForm('friend_message');
432-
433434
You can also easily embed the form type into another form::
434435

435436
// inside some other "form type" class

cookbook/security/form_login_setup.rst

-7
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ In this entry, you'll build a traditional login form. Of course, when the
1212
user logs in, you can load your users from anywhere - like the database.
1313
See :ref:`security-user-providers` for details.
1414

15-
This chapter assumes that you've followed the beginning of the
16-
:doc:`security chapter </book/security>` and have ``http_basic`` authentication
17-
working properly.
18-
1915
First, enable form login under your firewall:
2016

2117
.. configuration-block::
@@ -29,7 +25,6 @@ First, enable form login under your firewall:
2925
firewalls:
3026
default:
3127
anonymous: ~
32-
http_basic: ~
3328
form_login:
3429
login_path: /login
3530
check_path: /login_check
@@ -47,7 +42,6 @@ First, enable form login under your firewall:
4742
<config>
4843
<firewall name="default">
4944
<anonymous />
50-
<http-basic />
5145
<form-login login-path="/login" check-path="/login_check" />
5246
</firewall>
5347
</config>
@@ -60,7 +54,6 @@ First, enable form login under your firewall:
6054
'firewalls' => array(
6155
'default' => array(
6256
'anonymous' => null,
63-
'http_basic' => null,
6457
'form_login' => array(
6558
'login_path' => '/login',
6659
'check_path' => '/login_check',

create_framework/dependency-injection.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ them. Objects will be created on-demand when you access them from the
132132
container or when the container needs them to create other objects.
133133

134134
For instance, to create the router listener, we tell Symfony that its class
135-
name is ``Symfony\Component\HttpKernel\EventListener\RouterListener``, and
135+
name is ``Symfony\Component\HttpKernel\EventListener\RouterListener`` and
136136
that its constructor takes a matcher object (``new Reference('matcher')``). As
137137
you can see, each object is referenced by a name, a string that uniquely
138138
identifies each object. The name allows us to get an object and to reference

0 commit comments

Comments
 (0)