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
820a633c
Commit
820a633c
authored
Sep 13, 2012
by
Crell
Committed by
effulgentsia
Oct 01, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Documentation fixes.
parent
867e7707
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
66 deletions
+31
-66
core/lib/Drupal/Core/EventSubscriber/RouteProcessorSubscriber.php
.../Drupal/Core/EventSubscriber/RouteProcessorSubscriber.php
+2
-26
core/lib/Drupal/Core/HtmlPageController.php
core/lib/Drupal/Core/HtmlPageController.php
+24
-39
core/modules/system/lib/Drupal/system/Tests/Routing/RouterTest.php
...les/system/lib/Drupal/system/Tests/Routing/RouterTest.php
+5
-1
No files found.
core/lib/Drupal/Core/EventSubscriber/RouteProcessorSubscriber.php
View file @
820a633c
...
...
@@ -2,7 +2,7 @@
/**
* @file
* Definition of Drupal\Core\EventSubscriber\Route
rListen
er.
* Definition of Drupal\Core\EventSubscriber\Route
ProcessorSubscrib
er.
*/
namespace
Drupal\Core\EventSubscriber
;
...
...
@@ -18,33 +18,10 @@
use
Symfony\Component\Routing\Exception\ResourceNotFoundException
;
/**
* Drupal-specific Router listener.
*
* This is the bridge from the kernel to the UrlMatcher.
* Listener to process request controller information.
*/
class
RouteProcessorSubscriber
implements
EventSubscriberInterface
{
/**
* The Matcher object for this listener.
*
* This property is private in the base class, so we have to hack around it.
*
* @var Symfony\Component\Router\Matcher\UrlMatcherInterface
*/
protected
$urlMatcher
;
/**
* The Logging object for this listener.
*
* This property is private in the base class, so we have to hack around it.
*
* @var Symfony\Component\HttpKernel\Log\LoggerInterface
*/
protected
$logger
;
public
function
__construct
()
{
}
/**
* Sets a default controller for a route if one was not specified.
*/
...
...
@@ -54,7 +31,6 @@ public function onRequestSetController(GetResponseEvent $event) {
if
(
!
$request
->
attributes
->
has
(
'_controller'
)
&&
$request
->
attributes
->
has
(
'_content'
))
{
$request
->
attributes
->
set
(
'_controller'
,
'\Drupal\Core\HtmlPageController::content'
);
}
}
/**
...
...
core/lib/Drupal/Core/HtmlPageController.php
View file @
820a633c
<?php
/**
* @file
* Definition of Drupal\Core\HtmlPageController.
*/
namespace
Drupal\Core
;
use
Symfony\Component\HttpFoundation\Request
;
...
...
@@ -7,6 +12,9 @@
use
Symfony\Component\DependencyInjection\ContainerAwareInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
/**
* Default controller for most HTML pages.
*/
class
HtmlPageController
implements
ContainerAwareInterface
{
/**
...
...
@@ -16,10 +24,25 @@ class HtmlPageController implements ContainerAwareInterface {
*/
protected
$container
;
/**
* Injects the service container used by this object.
*
* @param ContainerInterface $container
* The service container this object should use.
*/
public
function
setContainer
(
ContainerInterface
$container
=
NULL
)
{
$this
->
container
=
$container
;
}
/**
* Controller method for generic HTML pages.
*
* @param Request $request
* The request object.
* @param type $_content
* The body content callable that contains the body region of this page.
* @return \Symfony\Component\HttpFoundation\Response
*/
public
function
content
(
Request
$request
,
$_content
)
{
// @todo When we have a Generator, we can replace the forward() call with
...
...
@@ -28,7 +51,7 @@ public function content(Request $request, $_content) {
// 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'
)
;
$controller
=
$
_content
;
$attributes
->
remove
(
'system_path'
);
$attributes
->
remove
(
'_content'
);
$response
=
$this
->
container
->
get
(
'http_kernel'
)
->
forward
(
$controller
,
$attributes
->
all
(),
$request
->
query
->
all
());
...
...
@@ -37,42 +60,4 @@ public function content(Request $request, $_content) {
return
new
Response
(
drupal_render_page
(
$page_content
));
}
protected
function
getContentController
(
$controller
)
{
if
(
is_array
(
$controller
)
||
(
is_object
(
$controller
)
&&
method_exists
(
$controller
,
'__invoke'
)))
{
return
$controller
;
}
if
(
FALSE
===
strpos
(
$controller
,
':'
))
{
if
(
method_exists
(
$controller
,
'__invoke'
))
{
return
new
$controller
;
}
elseif
(
function_exists
(
$controller
))
{
return
$controller
;
}
}
list
(
$controller
,
$method
)
=
$this
->
createController
(
$controller
);
if
(
!
method_exists
(
$controller
,
$method
))
{
throw
new
\
InvalidArgumentException
(
sprintf
(
'Method "%s::%s" does not exist.'
,
get_class
(
$controller
),
$method
));
}
return
array
(
$controller
,
$method
);
}
protected
function
createController
(
$controller
)
{
if
(
false
===
strpos
(
$controller
,
'::'
))
{
throw
new
\
InvalidArgumentException
(
sprintf
(
'Unable to find controller "%s".'
,
$controller
));
}
list
(
$class
,
$method
)
=
explode
(
'::'
,
$controller
,
2
);
if
(
!
class_exists
(
$class
))
{
throw
new
\
InvalidArgumentException
(
sprintf
(
'Class "%s" does not exist.'
,
$class
));
}
return
array
(
new
$class
(),
$method
);
}
}
core/modules/system/lib/Drupal/system/Tests/Routing/RouterTest.php
View file @
820a633c
<?php
/**
* @file
* Definition of Drupal\system\Tests\Routing\RouterTest.
*/
namespace
Drupal\system\Tests\Routing
;
use
Drupal\Core\Database\Database
;
use
Drupal\simpletest\WebTestBase
;
/**
...
...
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