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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 7 additions & 18 deletions
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

Lines changed: 7 additions & 9 deletions
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

Lines changed: 12 additions & 10 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 91 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 1 addition & 19 deletions
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

0 commit comments

Comments
 (0)