Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
drupal
Commits
a6b80d65
Commit
a6b80d65
authored
Jan 16, 2013
by
Crell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Docs improvements and remove unnecessary "use" statements.
parent
f5769e0a
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
96 additions
and
16 deletions
+96
-16
core/lib/Drupal/Core/Routing/MatcherDumper.php
core/lib/Drupal/Core/Routing/MatcherDumper.php
+0
-1
core/lib/Drupal/Core/Routing/MimeTypeMatcher.php
core/lib/Drupal/Core/Routing/MimeTypeMatcher.php
+1
-1
core/lib/Drupal/Core/Routing/NullGenerator.php
core/lib/Drupal/Core/Routing/NullGenerator.php
+9
-0
core/lib/Drupal/Core/Routing/UrlGenerator.php
core/lib/Drupal/Core/Routing/UrlGenerator.php
+16
-1
core/modules/system/lib/Drupal/system/Tests/Routing/MimeTypeMatcherTest.php
...m/lib/Drupal/system/Tests/Routing/MimeTypeMatcherTest.php
+0
-2
core/modules/system/lib/Drupal/system/Tests/Routing/MockAliasManager.php
...stem/lib/Drupal/system/Tests/Routing/MockAliasManager.php
+38
-1
core/modules/system/lib/Drupal/system/Tests/Routing/MockController.php
...system/lib/Drupal/system/Tests/Routing/MockController.php
+4
-1
core/modules/system/lib/Drupal/system/Tests/Routing/MockMatcher.php
...es/system/lib/Drupal/system/Tests/Routing/MockMatcher.php
+10
-7
core/modules/system/lib/Drupal/system/Tests/Routing/MockRouteProvider.php
...tem/lib/Drupal/system/Tests/Routing/MockRouteProvider.php
+18
-0
core/modules/system/lib/Drupal/system/Tests/Routing/RouteTest.php
...ules/system/lib/Drupal/system/Tests/Routing/RouteTest.php
+0
-1
core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ProviderBasedGenerator.php
.../Symfony/Cmf/Component/Routing/ProviderBasedGenerator.php
+0
-1
No files found.
core/lib/Drupal/Core/Routing/MatcherDumper.php
View file @
a6b80d65
...
...
@@ -8,7 +8,6 @@
namespace
Drupal\Core\Routing
;
use
Symfony\Component\Routing\Matcher\Dumper\MatcherDumperInterface
;
use
Symfony\Component\Routing\Route
;
use
Symfony\Component\Routing\RouteCollection
;
use
Drupal\Core\Database\Connection
;
...
...
core/lib/Drupal/Core/Routing/MimeTypeMatcher.php
View file @
a6b80d65
...
...
@@ -19,7 +19,7 @@ class MimeTypeMatcher implements RouteFilterInterface {
/**
*
{@inheritDoc}
*
Implements \Symfony\Cmf\Component\Routing\NestedMatcher\RouteFilterInterface::filter()
*/
public
function
filter
(
RouteCollection
$collection
,
Request
$request
)
{
// Generates a list of Symfony formats matching the acceptable MIME types.
...
...
core/lib/Drupal/Core/Routing/NullGenerator.php
View file @
a6b80d65
...
...
@@ -15,13 +15,22 @@
*/
class
NullGenerator
implements
UrlGeneratorInterface
{
/**
* Implements Symfony\Component\Routing\Generator\UrlGeneratorInterface::generate();
*/
public
function
generate
(
$name
,
$parameters
=
array
(),
$absolute
=
FALSE
)
{
throw
new
RouteNotFoundException
();
}
/**
* Implements Symfony\Component\Routing\RequestContextAwareInterface::setContext();
*/
public
function
setContext
(
RequestContext
$context
)
{
}
/**
* Implements Symfony\Component\Routing\RequestContextAwareInterface::getContext();
*/
public
function
getContext
()
{
}
}
core/lib/Drupal/Core/Routing/UrlGenerator.php
View file @
a6b80d65
...
...
@@ -7,13 +7,15 @@
namespace
Drupal\Core\Routing
;
use
Symfony\Component\HttpKernel\Log\LoggerInterface
;
use
Symfony\Cmf\Component\Routing\ProviderBasedGenerator
;
use
Symfony\Cmf\Component\Routing\RouteProviderInterface
;
use
Drupal\Core\Path\AliasManagerInterface
;
/**
*
Description of UrlGenerator
*
A Generator creates URL strings based on a specified route.
*/
class
UrlGenerator
extends
ProviderBasedGenerator
{
...
...
@@ -24,12 +26,25 @@ class UrlGenerator extends ProviderBasedGenerator {
*/
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
)
{
parent
::
__construct
(
$provider
,
$logger
);
$this
->
aliasManager
=
$alias_manager
;
}
/**
* Implements Symfony\Component\Routing\Generator\UrlGeneratorInterface::generate();
*/
public
function
generate
(
$name
,
$parameters
=
array
(),
$absolute
=
FALSE
)
{
$path
=
parent
::
generate
(
$name
,
$parameters
,
$absolute
);
...
...
core/modules/system/lib/Drupal/system/Tests/Routing/MimeTypeMatcherTest.php
View file @
a6b80d65
...
...
@@ -7,9 +7,7 @@
namespace
Drupal\system\Tests\Routing
;
use
Drupal\Core\Routing\FirstEntryFinalMatcher
;
use
Drupal\Core\Routing\MimeTypeMatcher
;
use
Drupal\Core\Routing\NestedMatcher
;
use
Drupal\simpletest\UnitTestBase
;
use
Symfony\Component\HttpFoundation\Request
;
...
...
core/modules/system/lib/Drupal/system/Tests/Routing/MockAliasManager.php
View file @
a6b80d65
...
...
@@ -17,16 +17,41 @@ class MockAliasManager implements AliasManagerInterface {
/**
* Array of mocked aliases. Keys are system paths, followed by language.
*
* @var
type
* @var
array
*/
protected
$aliases
=
array
();
/**
* Array of mocked aliases. Keys are aliases, followed by language.
*
* @var array
*/
protected
$systemPaths
=
array
();
/**
* An index of aliases that have been requested.
*
* @var array
*/
protected
$lookedUp
=
array
();
/**
* The language to assume a path alias is for if not specified.
*
* @var string
*/
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
)
{
$language
=
$path_language
?:
$this
->
defaultLanguage
;
...
...
@@ -34,21 +59,33 @@ public function addAlias($path, $alias, $path_language = NULL) {
$this
->
systemPaths
[
$alias
][
$language
]
=
$path
;
}
/**
* Implements \Drupal\Core\Path\AliasManagerInterface::getSystemPath().
*/
public
function
getSystemPath
(
$path
,
$path_language
=
NULL
)
{
$language
=
$path_language
?:
$this
->
defaultLanguage
;
return
$this
->
systemPaths
[
$path
][
$language
];
}
/**
* Implements \Drupal\Core\Path\AliasManagerInterface::getPathAlias().
*/
public
function
getPathAlias
(
$path
,
$path_language
=
NULL
)
{
$language
=
$path_language
?:
$this
->
defaultLanguage
;
$this
->
lookedUp
[
$path
]
=
1
;
return
$this
->
aliases
[
$path
][
$language
];
}
/**
* Implements \Drupal\Core\Path\AliasManagerInterface::getPathLookups().
*/
public
function
getPathLookups
()
{
return
array_keys
(
$this
->
lookedUp
);
}
/**
* Implements \Drupal\Core\Path\AliasManagerInterface::preloadPathLookups().
*/
public
function
preloadPathLookups
(
array
$path_list
)
{
// Not needed.
}
...
...
core/modules/system/lib/Drupal/system/Tests/Routing/MockController.php
View file @
a6b80d65
...
...
@@ -2,7 +2,7 @@
/**
* @file
*
Definition of
Drupal\system\Tests\Routing\MockController.
*
Contains
Drupal\system\Tests\Routing\MockController.
*/
namespace
Drupal\system\Tests\Routing
;
...
...
@@ -14,6 +14,9 @@
*/
class
MockController
extends
ContainerAware
{
/**
* Does nothing; this is just a fake controller method.
*/
public
function
run
()
{}
}
core/modules/system/lib/Drupal/system/Tests/Routing/MockMatcher.php
View file @
a6b80d65
...
...
@@ -9,15 +9,9 @@
use
Symfony\Component\HttpFoundation\Request
;
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.
*
*/
class
MockMatcher
implements
RequestMatcherInterface
{
...
...
@@ -26,10 +20,19 @@ class MockMatcher implements RequestMatcherInterface {
*/
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
;
}
/**
* Implements \Symfony\Component\Routing\Matcher\RequestMatcherInterface::matchRequest().
*/
public
function
matchRequest
(
Request
$request
)
{
$matcher
=
$this
->
matcher
;
return
$matcher
(
$request
);
...
...
core/modules/system/lib/Drupal/system/Tests/Routing/MockRouteProvider.php
View file @
a6b80d65
...
...
@@ -18,19 +18,34 @@
class
MockRouteProvider
implements
RouteProviderInterface
{
/**
* A collection of routes for this route provider.
*
* @var RouteCollection
*/
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
)
{
$this
->
routes
=
$routes
;
}
/**
* Implements \Symfony\Cmf\Component\Routing\RouteProviderInterface::getRouteCollectionForRequest().
*
* Not implemented at present as it is not needed.
*/
public
function
getRouteCollectionForRequest
(
Request
$request
)
{
}
/**
* Implements \Symfony\Cmf\Component\Routing\RouteProviderInterface::getRouteByName().
*/
public
function
getRouteByName
(
$name
,
$parameters
=
array
())
{
$routes
=
$this
->
getRoutesByNames
(
array
(
$name
),
$parameters
);
if
(
empty
(
$routes
))
{
...
...
@@ -40,6 +55,9 @@ public function getRouteByName($name, $parameters = array()) {
return
reset
(
$routes
);
}
/**
* Implements \Symfony\Cmf\Component\Routing\RouteProviderInterface::getRoutesByName().
*/
public
function
getRoutesByNames
(
$names
,
$parameters
=
array
())
{
$routes
=
array
();
foreach
(
$names
as
$name
)
{
...
...
core/modules/system/lib/Drupal/system/Tests/Routing/RouteTest.php
View file @
a6b80d65
...
...
@@ -10,7 +10,6 @@
use
Symfony\Component\Routing\Route
;
use
Drupal\simpletest\UnitTestBase
;
use
Drupal\Core\Database\Database
;
/**
* Basic tests for the Route.
...
...
core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ProviderBasedGenerator.php
View file @
a6b80d65
...
...
@@ -6,7 +6,6 @@
use
Symfony\Component\Routing\Exception\RouteNotFoundException
;
use
Symfony\Component\Routing\Generator\UrlGenerator
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\HttpKernel\Log\LoggerInterface
;
use
Symfony\Cmf\Component\Routing\RouteProviderInterface
;
...
...
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