Rename UrlMatcherDumper to MatcherDumper, since we use more than just the Url for matching.
parent
806ff4acc8
commit
db11de09c8
|
@ -9,9 +9,9 @@ use Symfony\Component\Routing\RouteCollection;
|
||||||
use Drupal\Core\Database\Connection;
|
use Drupal\Core\Database\Connection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of UrlMatcherDumper.
|
* Dumps Route information to a database table.
|
||||||
*/
|
*/
|
||||||
class UrlMatcherDumper implements MatcherDumperInterface {
|
class MatcherDumper implements MatcherDumperInterface {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The maximum number of path elements for a route pattern;
|
* The maximum number of path elements for a route pattern;
|
|
@ -1,100 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
* Definition of Drupal\Core\Routing\UrlMatcher.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Drupal\Core\Routing;
|
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
|
||||||
use Symfony\Component\Routing\Matcher\UrlMatcherInterface;
|
|
||||||
use Symfony\Component\Routing\RequestContext;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* UrlMatcher matches URL based on a set of routes.
|
|
||||||
*/
|
|
||||||
class UrlMatcher implements UrlMatcherInterface {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The request context for this matcher.
|
|
||||||
*
|
|
||||||
* @var Symfony\Component\Routing\RequestContext
|
|
||||||
*/
|
|
||||||
protected $context;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The request object for this matcher.
|
|
||||||
*
|
|
||||||
* @var Symfony\Component\HttpFoundation\Request
|
|
||||||
*/
|
|
||||||
protected $request;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
*/
|
|
||||||
public function __construct() {
|
|
||||||
// We will not actually use this object, but it's needed to conform to
|
|
||||||
// the interface.
|
|
||||||
$this->context = new RequestContext();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the request context.
|
|
||||||
*
|
|
||||||
* This method is just to satisfy the interface, and is largely vestigial.
|
|
||||||
* The request context object does not contain the information we need, so
|
|
||||||
* we will use the original request object.
|
|
||||||
*
|
|
||||||
* @param Symfony\Component\Routing\RequestContext $context
|
|
||||||
* The context.
|
|
||||||
*
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
public function setContext(RequestContext $context) {
|
|
||||||
$this->context = $context;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the request context.
|
|
||||||
*
|
|
||||||
* This method is just to satisfy the interface, and is largely vestigial.
|
|
||||||
* The request context object does not contain the information we need, so
|
|
||||||
* we will use the original request object.
|
|
||||||
*
|
|
||||||
* @return Symfony\Component\Routing\RequestContext
|
|
||||||
* The context.
|
|
||||||
*/
|
|
||||||
public function getContext() {
|
|
||||||
return $this->context;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the request object to use.
|
|
||||||
*
|
|
||||||
* This is used by the RouterListener to make additional request attributes
|
|
||||||
* available.
|
|
||||||
*
|
|
||||||
* @param Symfony\Component\HttpFoundation\Request $request
|
|
||||||
* The request object.
|
|
||||||
*/
|
|
||||||
public function setRequest(Request $request) {
|
|
||||||
$this->request = $request;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the request object.
|
|
||||||
*
|
|
||||||
* @return Symfony\Component\HttpFoundation\Request $request
|
|
||||||
* The request object.
|
|
||||||
*/
|
|
||||||
public function getRequest() {
|
|
||||||
return $this->request;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function match($pathinfo) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -12,12 +12,12 @@ use Symfony\Component\Routing\RouteCollection;
|
||||||
|
|
||||||
use Drupal\simpletest\UnitTestBase;
|
use Drupal\simpletest\UnitTestBase;
|
||||||
use Drupal\Core\Database\Database;
|
use Drupal\Core\Database\Database;
|
||||||
use Drupal\Core\Routing\UrlMatcherDumper;
|
use Drupal\Core\Routing\MatcherDumper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic tests for the UrlMatcherDumper.
|
* Basic tests for the UrlMatcherDumper.
|
||||||
*/
|
*/
|
||||||
class UrlMatcherDumperTest extends UnitTestBase {
|
class MatcherDumperTest extends UnitTestBase {
|
||||||
public static function getInfo() {
|
public static function getInfo() {
|
||||||
return array(
|
return array(
|
||||||
'name' => 'Dumper tests',
|
'name' => 'Dumper tests',
|
||||||
|
@ -35,9 +35,9 @@ class UrlMatcherDumperTest extends UnitTestBase {
|
||||||
*/
|
*/
|
||||||
function testCreate() {
|
function testCreate() {
|
||||||
$connection = Database::getConnection();
|
$connection = Database::getConnection();
|
||||||
$dumper= new UrlMatcherDumper($connection);
|
$dumper= new MatcherDumper($connection);
|
||||||
|
|
||||||
$class_name = 'Drupal\Core\Routing\UrlMatcherDumper';
|
$class_name = 'Drupal\Core\Routing\MatcherDumper';
|
||||||
$this->assertTrue($dumper instanceof $class_name, t('Dumper created successfully'));
|
$this->assertTrue($dumper instanceof $class_name, t('Dumper created successfully'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ class UrlMatcherDumperTest extends UnitTestBase {
|
||||||
*/
|
*/
|
||||||
function testAddRoutes() {
|
function testAddRoutes() {
|
||||||
$connection = Database::getConnection();
|
$connection = Database::getConnection();
|
||||||
$dumper= new UrlMatcherDumper($connection);
|
$dumper= new MatcherDumper($connection);
|
||||||
|
|
||||||
$route = new Route('test');
|
$route = new Route('test');
|
||||||
$collection = new RouteCollection();
|
$collection = new RouteCollection();
|
||||||
|
@ -67,7 +67,7 @@ class UrlMatcherDumperTest extends UnitTestBase {
|
||||||
*/
|
*/
|
||||||
function testAddAdditionalRoutes() {
|
function testAddAdditionalRoutes() {
|
||||||
$connection = Database::getConnection();
|
$connection = Database::getConnection();
|
||||||
$dumper= new UrlMatcherDumper($connection);
|
$dumper= new MatcherDumper($connection);
|
||||||
|
|
||||||
$route = new Route('test');
|
$route = new Route('test');
|
||||||
$collection = new RouteCollection();
|
$collection = new RouteCollection();
|
||||||
|
@ -103,7 +103,7 @@ class UrlMatcherDumperTest extends UnitTestBase {
|
||||||
*/
|
*/
|
||||||
public function testDump() {
|
public function testDump() {
|
||||||
$connection = Database::getConnection();
|
$connection = Database::getConnection();
|
||||||
$dumper= new UrlMatcherDumper($connection, 'test_routes');
|
$dumper= new MatcherDumper($connection, 'test_routes');
|
||||||
|
|
||||||
$route = new Route('/test/{my}/path');
|
$route = new Route('/test/{my}/path');
|
||||||
$route->setOption('compiler_class', 'Drupal\Core\Routing\RouteCompiler');
|
$route->setOption('compiler_class', 'Drupal\Core\Routing\RouteCompiler');
|
Loading…
Reference in New Issue