Skip to content

Commit 7574e8b

Browse files
committed
Merge branch '2.3' into 2.6
Conflicts: reference/configuration/framework.rst
2 parents e2d4986 + 7c1507c commit 7574e8b

File tree

8 files changed

+945
-176
lines changed

8 files changed

+945
-176
lines changed

book/forms.rst

+4
Original file line numberDiff line numberDiff line change
@@ -1591,13 +1591,17 @@ override the default error rendering for *all* fields, copy and customize the
15911591
.. index::
15921592
single: Forms; Global Theming
15931593

1594+
.. _book-forms-theming-global:
1595+
15941596
Global Form Theming
15951597
~~~~~~~~~~~~~~~~~~~
15961598

15971599
In the above example, you used the ``form_theme`` helper (in Twig) to "import"
15981600
the custom form fragments into *just* that form. You can also tell Symfony
15991601
to import form customizations across your entire project.
16001602

1603+
.. _book-forms-theming-twig:
1604+
16011605
Twig
16021606
....
16031607

book/http_cache.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,8 @@ of the master page.
11571157
With ESI, the full page cache will be valid for 600 seconds, but the news
11581158
component cache will only last for 60 seconds.
11591159

1160+
.. _book-http_cache-fragments:
1161+
11601162
When using a controller reference, the ESI tag should reference the embedded
11611163
action as an accessible URL so the gateway cache can fetch it independently of
11621164
the rest of the page. Symfony takes care of generating a unique URL for any

book/routing.rst

+2
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,8 @@ URL Route Parameters
543543
.. index::
544544
single: Routing; Requirements
545545

546+
.. _book-routing-requirements:
547+
546548
Adding Requirements
547549
~~~~~~~~~~~~~~~~~~~
548550

book/templating.rst

+2
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,8 @@ Controllers are fast to execute and promote good code organization and reuse.
679679
Of course, like all controllers, they should ideally be "skinny", meaning
680680
that as much code as possible lives in reusable :doc:`services </book/service_container>`.
681681

682+
.. _book-templating-hinclude:
683+
682684
Asynchronous Content with hinclude.js
683685
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
684686

book/translation.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,9 @@ in your application.
532532
.. index::
533533
single: Translations; Fallback and default locale
534534

535-
Setting a default Locale
535+
.. _book-translation-default-locale:
536+
537+
Setting a Default Locale
536538
~~~~~~~~~~~~~~~~~~~~~~~~
537539

538540
What if the user's locale hasn't been determined? You can guarantee that a

cookbook/controller/error_pages.rst

+37-29
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Error pages for the production environment can be customized in different ways
2727
depending on your needs:
2828

2929
#. If you just want to change the contents and styles of the error pages to match
30-
the rest of your application, :ref:`override default error templates <use-default-exception-controller>`;
30+
the rest of your application, :ref:`override the default error templates <use-default-exception-controller>`;
3131

3232
#. If you also want to tweak the logic used by Symfony to generate error pages,
3333
:ref:`override the default exception controller <custom-exception-controller>`;
@@ -41,25 +41,16 @@ depending on your needs:
4141
Overriding the Default Error Templates
4242
--------------------------------------
4343

44-
By default, the ``showAction()`` method of the
45-
:class:`Symfony\\Bundle\\TwigBundle\\Controller\\ExceptionController` is called
46-
whenever an exception occurs, thanks to an event listener configured by the TwigBundle.
47-
48-
Then, the controller selects one of the templates defined in the
49-
``Resources/views/Exception`` directory of the TwigBundle to render the error
50-
page. If you browse that directory (usually located in
51-
``vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle``) you'll find a lot of
52-
templates defined for different types of errors and content formats
53-
(``error.*.twig`` templates are used in the production environment whereas
54-
``exception.*.twig`` templates are used in the development environment).
44+
When the error page loads, an internal :class:`Symfony\\Bundle\\TwigBundle\\Controller\\ExceptionController`
45+
is used to render a Twig template to show the user.
5546

5647
.. _cookbook-error-pages-by-status-code:
5748

58-
The logic followed by the ``ExceptionController`` to pick one of the available
59-
templates is based on the HTTP status code and the request format:
49+
This controller uses the HTTP status code, request format and the following
50+
logic to determine the template filename:
6051

6152
#. Look for a template for the given format and status code (like ``error404.json.twig``
62-
or ``error500.xml.twig``);
53+
or ``error500.html.twig``);
6354

6455
#. If the previous template doesn't exist, discard the status code and look for
6556
a generic template for the given format (like ``error.json.twig`` or
@@ -71,8 +62,29 @@ templates is based on the HTTP status code and the request format:
7162
.. _overriding-or-adding-templates:
7263

7364
To override these templates, simply rely on the standard Symfony method for
74-
:ref:`overriding templates that live inside a bundle <overriding-bundle-templates>`.
75-
For example, to override the 404 error template for HTML pages, create a new
65+
:ref:`overriding templates that live inside a bundle <overriding-bundle-templates>`:
66+
put them in the ``app/Resources/TwigBundle/views/Exception/`` directory.
67+
68+
A typical project that returns HTML and JSON pages, might look like this:
69+
70+
.. code-block:: text
71+
72+
app/
73+
└─ Resources/
74+
└─ TwigBundle/
75+
└─ views/
76+
└─ Exception/
77+
├─ error404.html.twig
78+
├─ error403.html.twig
79+
├─ error.html.twig # All other HTML errors (including 500)
80+
├─ error404.json.twig
81+
├─ error403.json.twig
82+
├─ error.json.twig # All other JSON errors (including 500)
83+
84+
Example 404 Error Template
85+
--------------------------
86+
87+
To override the 404 error template for HTML pages, create a new
7688
``error404.html.twig`` template located at ``app/Resources/TwigBundle/views/Exception/``:
7789

7890
.. code-block:: html+jinja
@@ -83,16 +95,17 @@ For example, to override the 404 error template for HTML pages, create a new
8395
{% block body %}
8496
<h1>Page not found</h1>
8597

98+
{# example security usage, see below #}
99+
{% if app.user and is_granted('IS_AUTHENTICATED_FULLY') %}
100+
{# ... #}
101+
{% endif %}
102+
86103
<p>
87104
The requested page couldn't be located. Checkout for any URL
88105
misspelling or <a href="{{ path('homepage') }}">return to the homepage</a>.
89106
</p>
90107
{% endblock %}
91108

92-
Commonly, Symfony applications redefine the ``error404.html.twig`` template, the
93-
``error500.html.twig`` template for internal server errors and the generic
94-
``error.html.twig`` template to catch any other error different from 404 and 500.
95-
96109
In case you need them, the ``ExceptionController`` passes some information to
97110
the error template via the ``status_code`` and ``status_text`` variables that
98111
store the HTTP status code and message respectively.
@@ -132,14 +145,9 @@ is undefined. The solution is to add the following check before using this funct
132145
Testing Error Pages during Development
133146
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
134147

135-
One of the biggest hurdles of testing how do custom error pages look in your
136-
application is the fact that Symfony ignores them in the development environment
137-
and displays the default exception pages instead.
138-
139-
You may be tempted to set the ``kernel.debug`` parameter to ``false`` to disable
140-
the debug mode in the development environment. However, this practice is not
141-
recommended because it will also stop Symfony from recompiling your Twig templates,
142-
among many other things.
148+
While you're in the development environment, Symfony shows the big *exception*
149+
page instead of your shiny new customized error page. So, how can you see
150+
what it looks like and debug it?
143151

144152
The recommended solution is to use a third-party bundle called `WebfactoryExceptionsBundle`_.
145153
This bundle provides a special test controller that allows you to easily display

cookbook/profiler/storage.rst

+8-8
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ uses MySQL as the storage for the profiler with a lifetime of one hour:
5858
));
5959
6060
The :doc:`HttpKernel component </components/http_kernel/introduction>` currently
61-
supports the following profiler storage implementations:
61+
supports the following profiler storage drivers:
6262

63-
* :class:`Symfony\\Component\\HttpKernel\\Profiler\\FileProfilerStorage`
64-
* :class:`Symfony\\Component\\HttpKernel\\Profiler\\MemcachedProfilerStorage`
65-
* :class:`Symfony\\Component\\HttpKernel\\Profiler\\MemcacheProfilerStorage`
66-
* :class:`Symfony\\Component\\HttpKernel\\Profiler\\MongoDbProfilerStorage`
67-
* :class:`Symfony\\Component\\HttpKernel\\Profiler\\MysqlProfilerStorage`
68-
* :class:`Symfony\\Component\\HttpKernel\\Profiler\\RedisProfilerStorage`
69-
* :class:`Symfony\\Component\\HttpKernel\\Profiler\\SqliteProfilerStorage`
63+
* file
64+
* sqlite
65+
* mysql
66+
* mongodb
67+
* memcache
68+
* memcached
69+
* redis

0 commit comments

Comments
 (0)