Skip to content
Snippets Groups Projects
Commit 820a633c authored by Larry Garfield's avatar Larry Garfield Committed by Alex Bronstein
Browse files

Documentation fixes.

parent 867e7707
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -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\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');
}
}
/**
......
<?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);
}
}
<?php
/**
* @file
* Definition of Drupal\system\Tests\Routing\RouterTest.
*/
namespace Drupal\system\Tests\Routing;
use Drupal\Core\Database\Database;
use Drupal\simpletest\WebTestBase;
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment