Skip to content

Commit 46b21bd

Browse files
committed
Merge branch '2.4' into 2.5
2 parents 140e54e + d6ad6a9 commit 46b21bd

File tree

3 files changed

+41
-20
lines changed

3 files changed

+41
-20
lines changed

cookbook/controller/error_pages.rst

+37-13
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,12 @@ the status code that should be set for the given exception.
1414
Error pages can be customized in two different ways, depending on how much
1515
control you need:
1616

17-
1. Customize the error templates of the different error pages (explained below);
17+
1. Customize the error templates of the different error pages;
1818

19-
2. Replace the default exception controller ``twig.controller.exception:showAction``
20-
with your own controller and handle it however you want (see
21-
:ref:`exception_controller in the Twig reference <config-twig-exception-controller>`).
22-
The default exception controller is registered as a service - the actual
23-
class is ``Symfony\Bundle\TwigBundle\Controller\ExceptionController``.
19+
2. Replace the default exception controller ``twig.controller.exception:showAction``.
2420

25-
.. tip::
26-
27-
The customization of exception handling is actually much more powerful
28-
than what's written here. An internal event, ``kernel.exception``, is thrown
29-
which allows complete control over exception handling. For more
30-
information, see :ref:`kernel-kernel.exception`.
21+
The default ExceptionController
22+
-------------------------------
3123

3224
The default ``ExceptionController`` will either display an
3325
*exception* or *error* page, depending on the setting of the ``kernel.debug``
@@ -43,9 +35,12 @@ shown to the end-user.
4335

4436
The third-party `WebfactoryExceptionsBundle`_ provides a special
4537
test controller that allows you to display your custom error
46-
pages for arbitrary HTTP status codes even with
38+
pages for arbitrary HTTP status codes even with
4739
``kernel.debug`` set to ``true``.
4840

41+
Override Error Templates
42+
------------------------
43+
4944
All of the error templates live inside the TwigBundle. To override the
5045
templates, simply rely on the standard method for overriding templates that
5146
live inside a bundle. For more information, see
@@ -129,3 +124,32 @@ Symfony uses the following algorithm to determine which template to use:
129124
``exception.json.twig`` for the JSON exception page.
130125

131126
.. _`WebfactoryExceptionsBundle`: https://github.com/webfactory/exceptions-bundle
127+
128+
Replace the default Exception Controller
129+
----------------------------------------
130+
131+
If you need a little more flexibility beyond just overriding the template
132+
(e.g. you need to pass some additional variables into your template),
133+
then you can override the controller that renders the error page.
134+
135+
The default exception controller is registered as a service - the actual
136+
class is ``Symfony\Bundle\TwigBundle\Controller\ExceptionController``.
137+
138+
To do this, create a new controller class and make it extend Symfony's default
139+
``Symfony\Bundle\TwigBundle\Controller\ExceptionController`` class.
140+
141+
There are several methods you can override to customize different parts of how
142+
the error page is rendered. You could, for example, override the entire
143+
``showAction`` or just the ``findTemplate`` method, which locates which
144+
template should be rendered.
145+
146+
To make Symfony use your exception controller instead of the default, set the
147+
:ref:`twig.exception_controller <config-twig-exception-controller>` option
148+
in app/config/config.yml.
149+
150+
.. tip::
151+
152+
The customization of exception handling is actually much more powerful
153+
than what's written here. An internal event, ``kernel.exception``, is thrown
154+
which allows complete control over exception handling. For more
155+
information, see :ref:`kernel-kernel.exception`.

cookbook/security/custom_authentication_provider.rst

-6
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,6 @@ set an authenticated token in the security context if successful.
159159
// $this->securityContext->setToken(null);
160160
// }
161161
// return;
162-
163-
// Deny authentication with a '403 Forbidden' HTTP response
164-
$response = new Response();
165-
$response->setStatusCode(Response::HTTP_FORBIDDEN);
166-
$event->setResponse($response);
167-
168162
}
169163
170164
// By default deny authorization

cookbook/security/pre_authenticated.rst

+4-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ in the x509 firewall configuration respectively.
7070

7171
An authentication provider will only inform the user provider of the username
7272
that made the request. You will need to create (or use) a "user provider" that
73-
turns that username into a User object of your choice:
73+
is referenced by the ``provider`` configuration parameter (``your_user_provider``
74+
in the configuration example). This provider will turn the username into a User
75+
object of your choice. For more information on creating or configuring a user
76+
provider, see:
7477

7578
* :doc:`/cookbook/security/custom_provider`
7679
* :doc:`/cookbook/security/entity_provider`

0 commit comments

Comments
 (0)