diff --git a/core/lib/Drupal/Core/EventSubscriber/RouteProcessorSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/RouteProcessorSubscriber.php index 816366657faf..cba2fce69fab 100644 --- a/core/lib/Drupal/Core/EventSubscriber/RouteProcessorSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/RouteProcessorSubscriber.php @@ -2,7 +2,7 @@ /** * @file - * Definition of Drupal\Core\EventSubscriber\RouterListener. + * Definition of Drupal\Core\EventSubscriber\RouteProcessorSubscriber. */ namespace Drupal\Core\EventSubscriber; @@ -18,33 +18,10 @@ use Symfony\Component\Routing\Matcher\UrlMatcherInterface; 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 @@ class RouteProcessorSubscriber implements EventSubscriberInterface { if (!$request->attributes->has('_controller') && $request->attributes->has('_content')) { $request->attributes->set('_controller', '\Drupal\Core\HtmlPageController::content'); } - } /** diff --git a/core/lib/Drupal/Core/HtmlPageController.php b/core/lib/Drupal/Core/HtmlPageController.php index b087b82c67d8..863f33f0e481 100644 --- a/core/lib/Drupal/Core/HtmlPageController.php +++ b/core/lib/Drupal/Core/HtmlPageController.php @@ -1,5 +1,10 @@ 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 @@ class HtmlPageController implements ContainerAwareInterface { // 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 @@ class HtmlPageController implements ContainerAwareInterface { 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); - } - - } diff --git a/core/modules/system/lib/Drupal/system/Tests/Routing/RouterTest.php b/core/modules/system/lib/Drupal/system/Tests/Routing/RouterTest.php index ac7d5b7239b4..58a90508d7c0 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Routing/RouterTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Routing/RouterTest.php @@ -1,8 +1,12 @@