Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
304
Merge Requests
304
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
867e7707
Commit
867e7707
authored
Sep 02, 2012
by
Crell
Committed by
effulgentsia
Oct 01, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass the _content callback as a proper controller through HttpKernel::forward().
parent
f6bf9630
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
12 deletions
+32
-12
core/lib/Drupal/Core/EventSubscriber/ViewSubscriber.php
core/lib/Drupal/Core/EventSubscriber/ViewSubscriber.php
+18
-7
core/lib/Drupal/Core/HtmlPageController.php
core/lib/Drupal/Core/HtmlPageController.php
+14
-5
No files found.
core/lib/Drupal/Core/EventSubscriber/ViewSubscriber.php
View file @
867e7707
...
...
@@ -10,6 +10,7 @@
use
Symfony\Component\HttpFoundation\Response
;
use
Symfony\Component\HttpFoundation\JsonResponse
;
use
Symfony\Component\HttpKernel\KernelEvents
;
use
Symfony\Component\HttpKernel\HttpKernelInterface
;
use
Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent
;
use
Symfony\Component\EventDispatcher\EventSubscriberInterface
;
...
...
@@ -44,15 +45,25 @@ public function __construct(ContentNegotiation $negotiation) {
*/
public
function
onView
(
GetResponseForControllerResultEvent
$event
)
{
$request
=
$event
->
getRequest
();
$method
=
'on'
.
$this
->
negotiation
->
getContentType
(
$request
);
if
(
method_exists
(
$this
,
$method
))
{
$event
->
setResponse
(
$this
->
$method
(
$event
));
// For a master request, we process the result and wrap it as needed.
// For a subrequest, all we want is the string value. We assume that
// is just an HTML string from a controller, so wrap that into a response
// object. The subrequest's response will get dissected and placed into
// the larger page as needed.
if
(
$event
->
getRequestType
()
==
HttpKernelInterface
::
MASTER_REQUEST
)
{
$request
=
$event
->
getRequest
();
$method
=
'on'
.
$this
->
negotiation
->
getContentType
(
$request
);
if
(
method_exists
(
$this
,
$method
))
{
$event
->
setResponse
(
$this
->
$method
(
$event
));
}
else
{
$event
->
setResponse
(
new
Response
(
'Unsupported Media Type'
,
415
));
}
}
else
{
$event
->
setResponse
(
new
Response
(
'Unsupported Media Type'
,
415
));
$event
->
setResponse
(
new
Response
(
$event
->
getControllerResult
()
));
}
}
...
...
core/lib/Drupal/Core/HtmlPageController.php
View file @
867e7707
...
...
@@ -22,11 +22,20 @@ public function setContainer(ContainerInterface $container = NULL) {
public
function
content
(
Request
$request
,
$_content
)
{
$content_controller
=
$this
->
getContentController
(
$_content
);
$page_callback_result
=
call_user_func_array
(
$content_controller
,
array
());
return
new
Response
(
drupal_render_page
(
$page_callback_result
));
// @todo When we have a Generator, we can replace the forward() call with
// a render() call, which would handle ESI and hInclude as well. That will
// require an _internal route. For examples, see:
// https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing/internal.xml
// https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Controller/InternalController.php
$attributes
=
$request
->
attributes
;
$controller
=
$attributes
->
get
(
'_content'
);
$attributes
->
remove
(
'system_path'
);
$attributes
->
remove
(
'_content'
);
$response
=
$this
->
container
->
get
(
'http_kernel'
)
->
forward
(
$controller
,
$attributes
->
all
(),
$request
->
query
->
all
());
$page_content
=
$response
->
getContent
();
return
new
Response
(
drupal_render_page
(
$page_content
));
}
protected
function
getContentController
(
$controller
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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