@@ -38,8 +38,8 @@ hash (with a salt using that token) to all our responses.
38
38
39
39
So, after generating a JSON response, this hash has to be added to the response.
40
40
41
- Before and after filters with kernel.controller / kernel.response events
42
- ------------------------------------------------------------------------
41
+ Before and after filters with `` kernel.controller `` / `` kernel.response `` events
42
+ --------------------------------------------------------------------------------
43
43
44
44
Basic Setup
45
45
~~~~~~~~~~~
@@ -86,24 +86,24 @@ request needs token validation. Regarding the response, you will also need
86
86
some way to identify that the response needs to be hashed.
87
87
88
88
A clean and easy way is to create an empty interface and make the controllers
89
- implement it:
89
+ implement it::
90
90
91
91
namespace Acme\DemoBundle\Controller;
92
92
93
93
interface TokenAuthenticatedController
94
94
{
95
- // Nothing here
95
+ // ...
96
96
}
97
97
98
- And also create a HashedResponse object extending Response
98
+ And also create a `` HashedResponse `` object extending `` Response ``
99
99
100
100
namespace Acme\D emoBundle\R esponse;
101
101
102
102
use Symfony\C omponent\H ttpFoundation\R esponse;
103
103
104
104
class HashedResponse extends Response
105
105
{
106
- // Nothing here
106
+ // ...
107
107
}
108
108
109
109
A controller that implements this interface simply looks like this::
@@ -172,7 +172,7 @@ event listeners, you can learn more about them at :doc:`/cookbook/service_contai
172
172
if ($response instanceof HashedResponse) {
173
173
$token = $event->getRequest()->get('token');
174
174
175
- $hash = sha1($response->getContent() . $token);
175
+ $hash = sha1($response->getContent(). $token);
176
176
177
177
$response->setContent(
178
178
json_encode(array(
0 commit comments