Commit a6b80d65 authored by Crell's avatar Crell
Browse files

Docs improvements and remove unnecessary "use" statements.

parent f5769e0a
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
namespace Drupal\Core\Routing; namespace Drupal\Core\Routing;
use Symfony\Component\Routing\Matcher\Dumper\MatcherDumperInterface; use Symfony\Component\Routing\Matcher\Dumper\MatcherDumperInterface;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\RouteCollection;
use Drupal\Core\Database\Connection; use Drupal\Core\Database\Connection;
......
...@@ -19,7 +19,7 @@ class MimeTypeMatcher implements RouteFilterInterface { ...@@ -19,7 +19,7 @@ class MimeTypeMatcher implements RouteFilterInterface {
/** /**
* {@inheritDoc} * Implements \Symfony\Cmf\Component\Routing\NestedMatcher\RouteFilterInterface::filter()
*/ */
public function filter(RouteCollection $collection, Request $request) { public function filter(RouteCollection $collection, Request $request) {
// Generates a list of Symfony formats matching the acceptable MIME types. // Generates a list of Symfony formats matching the acceptable MIME types.
......
...@@ -15,13 +15,22 @@ ...@@ -15,13 +15,22 @@
*/ */
class NullGenerator implements UrlGeneratorInterface { class NullGenerator implements UrlGeneratorInterface {
/**
* Implements Symfony\Component\Routing\Generator\UrlGeneratorInterface::generate();
*/
public function generate($name, $parameters = array(), $absolute = FALSE) { public function generate($name, $parameters = array(), $absolute = FALSE) {
throw new RouteNotFoundException(); throw new RouteNotFoundException();
} }
/**
* Implements Symfony\Component\Routing\RequestContextAwareInterface::setContext();
*/
public function setContext(RequestContext $context) { public function setContext(RequestContext $context) {
} }
/**
* Implements Symfony\Component\Routing\RequestContextAwareInterface::getContext();
*/
public function getContext() { public function getContext() {
} }
} }
...@@ -7,13 +7,15 @@ ...@@ -7,13 +7,15 @@
namespace Drupal\Core\Routing; namespace Drupal\Core\Routing;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Cmf\Component\Routing\ProviderBasedGenerator; use Symfony\Cmf\Component\Routing\ProviderBasedGenerator;
use Symfony\Cmf\Component\Routing\RouteProviderInterface; use Symfony\Cmf\Component\Routing\RouteProviderInterface;
use Drupal\Core\Path\AliasManagerInterface; use Drupal\Core\Path\AliasManagerInterface;
/** /**
* Description of UrlGenerator * A Generator creates URL strings based on a specified route.
*/ */
class UrlGenerator extends ProviderBasedGenerator { class UrlGenerator extends ProviderBasedGenerator {
...@@ -24,12 +26,25 @@ class UrlGenerator extends ProviderBasedGenerator { ...@@ -24,12 +26,25 @@ class UrlGenerator extends ProviderBasedGenerator {
*/ */
protected $aliasManager; protected $aliasManager;
/**
* Constructs a new generator object.
*
* @param \Symfony\Cmf\Component\Routing\RouteProviderInterface $provider
* The route provider to be searched for routes.
* @param \Drupal\Core\Path\AliasManagerInterface $alias_manager
* The alias manager responsible for path aliasing.
* @param \Symfony\Component\HttpKernel\Log\LoggerInterface $logger
* An optional logger for recording errors.
*/
public function __construct(RouteProviderInterface $provider, AliasManagerInterface $alias_manager, LoggerInterface $logger = NULL) { public function __construct(RouteProviderInterface $provider, AliasManagerInterface $alias_manager, LoggerInterface $logger = NULL) {
parent::__construct($provider, $logger); parent::__construct($provider, $logger);
$this->aliasManager = $alias_manager; $this->aliasManager = $alias_manager;
} }
/**
* Implements Symfony\Component\Routing\Generator\UrlGeneratorInterface::generate();
*/
public function generate($name, $parameters = array(), $absolute = FALSE) { public function generate($name, $parameters = array(), $absolute = FALSE) {
$path = parent::generate($name, $parameters, $absolute); $path = parent::generate($name, $parameters, $absolute);
......
...@@ -7,9 +7,7 @@ ...@@ -7,9 +7,7 @@
namespace Drupal\system\Tests\Routing; namespace Drupal\system\Tests\Routing;
use Drupal\Core\Routing\FirstEntryFinalMatcher;
use Drupal\Core\Routing\MimeTypeMatcher; use Drupal\Core\Routing\MimeTypeMatcher;
use Drupal\Core\Routing\NestedMatcher;
use Drupal\simpletest\UnitTestBase; use Drupal\simpletest\UnitTestBase;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
......
...@@ -17,16 +17,41 @@ class MockAliasManager implements AliasManagerInterface { ...@@ -17,16 +17,41 @@ class MockAliasManager implements AliasManagerInterface {
/** /**
* Array of mocked aliases. Keys are system paths, followed by language. * Array of mocked aliases. Keys are system paths, followed by language.
* *
* @var type * @var array
*/ */
protected $aliases = array(); protected $aliases = array();
/**
* Array of mocked aliases. Keys are aliases, followed by language.
*
* @var array
*/
protected $systemPaths = array(); protected $systemPaths = array();
/**
* An index of aliases that have been requested.
*
* @var array
*/
protected $lookedUp = array(); protected $lookedUp = array();
/**
* The language to assume a path alias is for if not specified.
*
* @var string
*/
public $defaultLanguage = 'en'; public $defaultLanguage = 'en';
/**
* Adds an alias to the in-memory alias table for this object.
*
* @param type $path
* The system path of the alias.
* @param type $alias
* The alias of the system path.
* @param type $path_language
* The language of this alias.
*/
public function addAlias($path, $alias, $path_language = NULL) { public function addAlias($path, $alias, $path_language = NULL) {
$language = $path_language ?: $this->defaultLanguage; $language = $path_language ?: $this->defaultLanguage;
...@@ -34,21 +59,33 @@ public function addAlias($path, $alias, $path_language = NULL) { ...@@ -34,21 +59,33 @@ public function addAlias($path, $alias, $path_language = NULL) {
$this->systemPaths[$alias][$language] = $path; $this->systemPaths[$alias][$language] = $path;
} }
/**
* Implements \Drupal\Core\Path\AliasManagerInterface::getSystemPath().
*/
public function getSystemPath($path, $path_language = NULL) { public function getSystemPath($path, $path_language = NULL) {
$language = $path_language ?: $this->defaultLanguage; $language = $path_language ?: $this->defaultLanguage;
return $this->systemPaths[$path][$language]; return $this->systemPaths[$path][$language];
} }
/**
* Implements \Drupal\Core\Path\AliasManagerInterface::getPathAlias().
*/
public function getPathAlias($path, $path_language = NULL) { public function getPathAlias($path, $path_language = NULL) {
$language = $path_language ?: $this->defaultLanguage; $language = $path_language ?: $this->defaultLanguage;
$this->lookedUp[$path] = 1; $this->lookedUp[$path] = 1;
return $this->aliases[$path][$language]; return $this->aliases[$path][$language];
} }
/**
* Implements \Drupal\Core\Path\AliasManagerInterface::getPathLookups().
*/
public function getPathLookups() { public function getPathLookups() {
return array_keys($this->lookedUp); return array_keys($this->lookedUp);
} }
/**
* Implements \Drupal\Core\Path\AliasManagerInterface::preloadPathLookups().
*/
public function preloadPathLookups(array $path_list) { public function preloadPathLookups(array $path_list) {
// Not needed. // Not needed.
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* @file * @file
* Definition of Drupal\system\Tests\Routing\MockController. * Contains Drupal\system\Tests\Routing\MockController.
*/ */
namespace Drupal\system\Tests\Routing; namespace Drupal\system\Tests\Routing;
...@@ -14,6 +14,9 @@ ...@@ -14,6 +14,9 @@
*/ */
class MockController extends ContainerAware { class MockController extends ContainerAware {
/**
* Does nothing; this is just a fake controller method.
*/
public function run() {} public function run() {}
} }
...@@ -9,15 +9,9 @@ ...@@ -9,15 +9,9 @@
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Matcher\RequestMatcherInterface; use Symfony\Component\Routing\Matcher\RequestMatcherInterface;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
use Closure;
/** /**
* A mock matcher that can be configured with any matching logic for testing. * A mock matcher that can be configured with any matching logic for testing.
*
*/ */
class MockMatcher implements RequestMatcherInterface { class MockMatcher implements RequestMatcherInterface {
...@@ -26,10 +20,19 @@ class MockMatcher implements RequestMatcherInterface { ...@@ -26,10 +20,19 @@ class MockMatcher implements RequestMatcherInterface {
*/ */
protected $matcher; protected $matcher;
public function __construct(Closure $matcher) { /**
* Constructs a MockMatcher object.
*
* @param \Closure $matcher
* An anonymous function that will be used for the matchRequest() method.
*/
public function __construct(\Closure $matcher) {
$this->matcher = $matcher; $this->matcher = $matcher;
} }
/**
* Implements \Symfony\Component\Routing\Matcher\RequestMatcherInterface::matchRequest().
*/
public function matchRequest(Request $request) { public function matchRequest(Request $request) {
$matcher = $this->matcher; $matcher = $this->matcher;
return $matcher($request); return $matcher($request);
......
...@@ -18,19 +18,34 @@ ...@@ -18,19 +18,34 @@
class MockRouteProvider implements RouteProviderInterface { class MockRouteProvider implements RouteProviderInterface {
/** /**
* A collection of routes for this route provider.
* *
* @var RouteCollection * @var RouteCollection
*/ */
protected $routes; protected $routes;
/**
* Constructs a new MockRouteProvider.
*
* @param \Symfony\Component\Routing\RouteCollection $routes
* The route collection to use for this provider.
*/
public function __construct(RouteCollection $routes) { public function __construct(RouteCollection $routes) {
$this->routes = $routes; $this->routes = $routes;
} }
/**
* Implements \Symfony\Cmf\Component\Routing\RouteProviderInterface::getRouteCollectionForRequest().
*
* Not implemented at present as it is not needed.
*/
public function getRouteCollectionForRequest(Request $request) { public function getRouteCollectionForRequest(Request $request) {
} }
/**
* Implements \Symfony\Cmf\Component\Routing\RouteProviderInterface::getRouteByName().
*/
public function getRouteByName($name, $parameters = array()) { public function getRouteByName($name, $parameters = array()) {
$routes = $this->getRoutesByNames(array($name), $parameters); $routes = $this->getRoutesByNames(array($name), $parameters);
if (empty($routes)) { if (empty($routes)) {
...@@ -40,6 +55,9 @@ public function getRouteByName($name, $parameters = array()) { ...@@ -40,6 +55,9 @@ public function getRouteByName($name, $parameters = array()) {
return reset($routes); return reset($routes);
} }
/**
* Implements \Symfony\Cmf\Component\Routing\RouteProviderInterface::getRoutesByName().
*/
public function getRoutesByNames($names, $parameters = array()) { public function getRoutesByNames($names, $parameters = array()) {
$routes = array(); $routes = array();
foreach ($names as $name) { foreach ($names as $name) {
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
use Symfony\Component\Routing\Route; use Symfony\Component\Routing\Route;
use Drupal\simpletest\UnitTestBase; use Drupal\simpletest\UnitTestBase;
use Drupal\Core\Database\Database;
/** /**
* Basic tests for the Route. * Basic tests for the Route.
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
use Symfony\Component\Routing\Exception\RouteNotFoundException; use Symfony\Component\Routing\Exception\RouteNotFoundException;
use Symfony\Component\Routing\Generator\UrlGenerator; use Symfony\Component\Routing\Generator\UrlGenerator;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Log\LoggerInterface; use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Cmf\Component\Routing\RouteProviderInterface; use Symfony\Cmf\Component\Routing\RouteProviderInterface;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment