Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
da00dcc3
Commit
da00dcc3
authored
Mar 31, 2012
by
Larry Garfield
Browse files
Switch to the new JsonResponse object from Symfony.
parent
edcc5bd5
Changes
1
Hide whitespace changes
Inline
Side-by-side
core/lib/Drupal/Core/ExceptionController.php
View file @
da00dcc3
...
...
@@ -10,6 +10,7 @@
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\HttpFoundation\Response
;
use
Symfony\Component\HttpFoundation\JsonResponse
;
use
Symfony\Component\HttpKernel\HttpKernelInterface
;
use
Symfony\Component\EventDispatcher\EventDispatcher
;
...
...
@@ -41,7 +42,7 @@ class ExceptionController {
/**
* Constructor
*
*
* @param HttpKernelInterface $kernel
* The kernel that spawned this controller, so that it can be reused
* for subrequests.
...
...
@@ -169,13 +170,6 @@ public function on404Html(FlattenException $exception, Request $request) {
return
$response
;
}
protected
function
createJsonResponse
()
{
$response
=
new
Response
();
$response
->
headers
->
set
(
'Content-Type'
,
'application/json; charset=utf-8'
);
return
$response
;
}
/**
* Processes an AccessDenied exception into an HTTP 403 response.
*
...
...
@@ -183,7 +177,7 @@ protected function createJsonResponse() {
* The Event to process.
*/
public
function
on403Json
(
FlattenException
$exception
,
Request
$request
)
{
$response
=
$this
->
create
JsonResponse
();
$response
=
new
JsonResponse
();
$response
->
setStatusCode
(
403
,
'Access Denied'
);
return
$response
;
}
...
...
@@ -195,7 +189,7 @@ public function on403Json(FlattenException $exception, Request $request) {
* The Event to process.
*/
public
function
on404Json
(
FlattenException
$exception
,
Request
$request
)
{
$response
=
$this
->
create
JsonResponse
();
$response
=
new
JsonResponse
();
$response
->
setStatusCode
(
404
,
'Not Found'
);
return
$response
;
}
...
...
@@ -207,7 +201,7 @@ public function on404Json(FlattenException $exception, Request $request) {
* The Event to process.
*/
public
function
on405Json
(
FlattenException
$exception
,
Request
$request
)
{
$response
=
$this
->
create
JsonResponse
();
$response
=
new
JsonResponse
();
$response
->
setStatusCode
(
405
,
'Method Not Allowed'
);
return
$response
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment