Commit fc49a03a authored by catch's avatar catch

Issue #2372507 by dawehner, mavimo, RavindraSingh: Remove _system_path from $request->attributes

parent 78ac4561
......@@ -280,6 +280,9 @@ services:
path.alias_manager:
class: Drupal\Core\Path\AliasManager
arguments: ['@path.alias_storage', '@path.alias_whitelist', '@language_manager', '@cache.data']
path.current:
class: Drupal\Core\Path\CurrentPathStack
arguments: ['@request_stack']
http_client:
class: Drupal\Core\Http\Client
tags:
......@@ -537,7 +540,7 @@ services:
arguments: ['@current_route_match']
router.route_provider:
class: Drupal\Core\Routing\RouteProvider
arguments: ['@database', '@router.builder', '@state']
arguments: ['@database', '@router.builder', '@state', '@path.current']
tags:
- { name: event_subscriber }
- { name: backend_overridable }
......@@ -548,6 +551,7 @@ services:
- { name: 'event_subscriber' }
router.matcher.final_matcher:
class: Drupal\Core\Routing\UrlMatcher
arguments: ['@path.current']
router.matcher:
class: Symfony\Cmf\Component\Routing\NestedMatcher\NestedMatcher
arguments: ['@router.route_provider']
......@@ -840,7 +844,7 @@ services:
class: Drupal\Core\EventSubscriber\PathSubscriber
tags:
- { name: event_subscriber }
arguments: ['@path.alias_manager', '@path_processor_manager']
arguments: ['@path.alias_manager', '@path_processor_manager', '@path.current']
finish_response_subscriber:
class: Drupal\Core\EventSubscriber\FinishResponseSubscriber
tags:
......
......@@ -1315,8 +1315,8 @@ function template_preprocess_html(&$variables) {
$variables['root_path'] = FALSE;
}
else {
$system_path = \Drupal::request()->attributes->get('_system_path');
$variables['root_path'] = explode('/', $system_path)[0];
$system_path = \Drupal::service('path.current')->getPath();
$variables['root_path'] = explode('/', $system_path)[1];
}
$site_config = \Drupal::config('system.site');
......
......@@ -7,6 +7,7 @@
namespace Drupal\Core\EventSubscriber;
use Drupal\Core\Url;
use Drupal\Core\Utility\Error;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Request;
......@@ -69,7 +70,7 @@ protected function getHandledFormats() {
* The event to process.
*/
public function on403(GetResponseForExceptionEvent $event) {
$this->makeSubrequest($event, 'system/403', Response::HTTP_FORBIDDEN);
$this->makeSubrequest($event, Url::fromRoute('system.403')->toString(), Response::HTTP_FORBIDDEN);
}
/**
......@@ -79,7 +80,7 @@ public function on403(GetResponseForExceptionEvent $event) {
* The event to process.
*/
public function on404(GetResponseForExceptionEvent $event) {
$this->makeSubrequest($event, 'system/404', Response::HTTP_NOT_FOUND);
$this->makeSubrequest($event, Url::fromRoute('system.404')->toString(), Response::HTTP_NOT_FOUND);
}
/**
......@@ -87,24 +88,26 @@ public function on404(GetResponseForExceptionEvent $event) {
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event
* The event to process
* @param string $path
* The path to which to make a subrequest for this error message.
* @param string $url
* The path/url to which to make a subrequest for this error message.
* @param int $status_code
* The status code for the error being handled.
*/
protected function makeSubrequest(GetResponseForExceptionEvent $event, $path, $status_code) {
protected function makeSubrequest(GetResponseForExceptionEvent $event, $url, $status_code) {
$request = $event->getRequest();
// @todo Remove dependency on the internal _system_path attribute:
// https://www.drupal.org/node/2293523.
$system_path = $request->attributes->get('_system_path');
if (!($url && $url[0] == '/')) {
$url = $request->getBasePath() . '/' . $url;
}
$current_url = $request->getBasePath() . $request->getPathInfo();
if ($path && $path != $system_path) {
if ($url != $request->getBasePath() . '/' && $url != $current_url) {
if ($request->getMethod() === 'POST') {
$sub_request = Request::create($request->getBaseUrl() . '/' . $path, 'POST', ['destination' => $system_path, '_exception_statuscode' => $status_code] + $request->request->all(), $request->cookies->all(), [], $request->server->all());
$sub_request = Request::create($url, 'POST', $this->drupalGetDestination() + ['_exception_statuscode' => $status_code] + $request->request->all(), $request->cookies->all(), [], $request->server->all());
}
else {
$sub_request = Request::create($request->getBaseUrl() . '/' . $path, 'GET', $request->query->all() + ['destination' => $system_path, '_exception_statuscode' => $status_code], $request->cookies->all(), [], $request->server->all());
$sub_request = Request::create($url, 'GET', $request->query->all() + $this->drupalGetDestination() + ['_exception_statuscode' => $status_code], $request->cookies->all(), [], $request->server->all());
}
try {
......@@ -130,4 +133,11 @@ protected function makeSubrequest(GetResponseForExceptionEvent $event, $path, $s
}
}
/**
* Wraps drupal_get_destination().
*/
protected function drupalGetDestination() {
return drupal_get_destination();
}
}
......@@ -45,9 +45,7 @@ public function __construct(LoggerChannelFactoryInterface $logger) {
*/
public function on403(GetResponseForExceptionEvent $event) {
$request = $event->getRequest();
// @todo Remove dependency on the internal _system_path attribute:
// https://www.drupal.org/node/2293523.
$this->logger->get('access denied')->warning(String::checkPlain($request->attributes->get('_system_path')));
$this->logger->get('access denied')->warning(String::checkPlain($request->getRequestUri()));
}
/**
......@@ -58,9 +56,7 @@ public function on403(GetResponseForExceptionEvent $event) {
*/
public function on404(GetResponseForExceptionEvent $event) {
$request = $event->getRequest();
// @todo Remove dependency on the internal _system_path attribute:
// https://www.drupal.org/node/2293523.
$this->logger->get('page not found')->warning(String::checkPlain($request->attributes->get('_system_path')));
$this->logger->get('page not found')->warning(String::checkPlain($request->getRequestUri()));
}
/**
......
......@@ -8,6 +8,7 @@
namespace Drupal\Core\EventSubscriber;
use Drupal\Core\Path\AliasManagerInterface;
use Drupal\Core\Path\CurrentPathStack;
use Drupal\Core\PathProcessor\InboundPathProcessorInterface;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\KernelEvents;
......@@ -34,9 +35,25 @@ class PathSubscriber implements EventSubscriberInterface {
*/
protected $pathProcessor;
public function __construct(AliasManagerInterface $alias_manager, InboundPathProcessorInterface $path_processor) {
/**
* The current path.
*
* @var \Drupal\Core\Path\CurrentPathStack
*/
protected $currentPath;
/**
* Constructs a new PathSubscriber instance.
*
* @param \Drupal\Core\Path\AliasManagerInterface $alias_manager
* @param \Drupal\Core\PathProcessor\InboundPathProcessorInterface $path_processor
* @param \Drupal\Core\Path\CurrentPathStack $current_path
* The current path.
*/
public function __construct(AliasManagerInterface $alias_manager, InboundPathProcessorInterface $path_processor, CurrentPathStack $current_path) {
$this->aliasManager = $alias_manager;
$this->pathProcessor = $path_processor;
$this->currentPath = $current_path;
}
/**
......@@ -49,7 +66,7 @@ public function onKernelRequestConvertPath(GetResponseEvent $event) {
$request = $event->getRequest();
$path = trim($request->getPathInfo(), '/');
$path = $this->pathProcessor->processInbound($path, $request);
$request->attributes->set('_system_path', $path);
$this->currentPath->setPath('/' . $path, $request);
// Set the cache key on the alias manager cache decorator.
if ($event->getRequestType() == HttpKernelInterface::MASTER_REQUEST) {
......
......@@ -137,12 +137,7 @@ public function redirectForm(FormStateInterface $form_state) {
// If no redirect was specified, redirect to the current path.
elseif ($redirect === NULL) {
$request = $this->requestStack->getCurrentRequest();
// @todo Remove dependency on the internal _system_path attribute:
// https://www.drupal.org/node/2293521.
$url = $this->urlGenerator->generateFromPath($request->attributes->get('_system_path'), array(
'query' => $request->query->all(),
'absolute' => TRUE,
));
$url = $this->urlGenerator->generateFromRoute('<current>', [], ['query' => $request->query->all(), 'absolute' => TRUE]);
}
if ($url) {
......
<?php
/**
* @file
* Contains \Drupal\Core\Path\CurrentPathStack.
*/
namespace Drupal\Core\Path;
use Symfony\Component\HttpFoundation\RequestStack;
/**
* Represents the current path for the current request.
*
* Note: You should not rely on paths but rather on route names / parameters or
* other indicators like context. For some fundamental parts, like routing or
* path processing, there is unfortunately no way around dealing with paths.
*/
class CurrentPathStack {
/**
* Static cache of paths.
*
* @var \SplObjectStorage
*/
protected $paths;
/**
* The request stack.
*
* @var \Symfony\Component\HttpFoundation\RequestStack
*/
protected $requestStack;
/**
* Constructs a new CurrentPathStack instance.
*
* @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
* The request stack.
*/
public function __construct(RequestStack $request_stack) {
$this->requestStack = $request_stack;
$this->paths = new \SplObjectStorage();
}
/**
* Returns the path of the current request.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* (optional) The request.
*
* @return string
* Returns the path, without leading slashes.
*/
public function getPath($request = NULL) {
if (!isset($request)) {
$request = $this->requestStack->getCurrentRequest();
}
if (!isset($this->paths[$request])) {
$this->paths[$request] = $request->getPathInfo();
}
return $this->paths[$request];
}
/**
* Sets the current path.
*
* @param string $path
* The path.
* @param \Symfony\Component\HttpFoundation\Request $request
* (optional) The request.
*
* @return $this
*/
public function setPath($path, $request = NULL) {
if (!isset($request)) {
$request = $this->requestStack->getCurrentRequest();
}
$this->paths[$request] = $path;
return $this;
}
}
......@@ -36,12 +36,18 @@ public function __construct(RouteMatchInterface $route_match) {
* {@inheritdoc}
*/
public function processOutbound($route_name, Route $route, array &$parameters) {
if (($route_name === '<current>') && ($current_route = $this->routeMatch->getRouteObject())) {
$route->setPath($current_route->getPath());
$route->setRequirements($current_route->getRequirements());
$route->setOptions($current_route->getOptions());
$route->setDefaults($current_route->getDefaults());
$parameters = array_merge($parameters, $this->routeMatch->getRawParameters()->all());
if ($route_name === '<current>') {
if ($current_route = $this->routeMatch->getRouteObject()) {
$route->setPath($current_route->getPath());
$route->setRequirements($current_route->getRequirements());
$route->setOptions($current_route->getOptions());
$route->setDefaults($current_route->getDefaults());
$parameters = array_merge($parameters, $this->routeMatch->getRawParameters()->all());
}
else {
// If we have no current route match available, point to the frontpage.
$route->setPath('/');
}
}
}
......
......@@ -8,6 +8,7 @@
namespace Drupal\Core\Routing;
use Drupal\Component\Utility\String;
use Drupal\Core\Path\CurrentPathStack;
use Drupal\Core\State\StateInterface;
use Symfony\Cmf\Component\Routing\PagedRouteCollection;
use Symfony\Cmf\Component\Routing\PagedRouteProviderInterface;
......@@ -59,6 +60,13 @@ class RouteProvider implements RouteProviderInterface, PagedRouteProviderInterfa
*/
protected $routes = array();
/**
* The current path.
*
* @var \Drupal\Core\Path\CurrentPathStack
*/
protected $currentPath;
/**
* Constructs a new PathMatcher.
*
......@@ -68,14 +76,17 @@ class RouteProvider implements RouteProviderInterface, PagedRouteProviderInterfa
* The route builder.
* @param \Drupal\Core\State\StateInterface $state
* The state.
* @param \Drupal\Core\Path\CurrentPathStack $current_path
* THe current path.
* @param string $table
* The table in the database to use for matching.
*/
public function __construct(Connection $connection, RouteBuilderInterface $route_builder, StateInterface $state, $table = 'router') {
public function __construct(Connection $connection, RouteBuilderInterface $route_builder, StateInterface $state, CurrentPathStack $current_path, $table = 'router') {
$this->connection = $connection;
$this->routeBuilder = $route_builder;
$this->state = $state;
$this->tableName = $table;
$this->currentPath = $current_path;
}
/**
......@@ -104,24 +115,9 @@ public function __construct(Connection $connection, RouteBuilderInterface $route
* @todo Should this method's found routes also be included in the cache?
*/
public function getRouteCollectionForRequest(Request $request) {
$path = $this->currentPath->getPath($request);
// The '_system_path' has language prefix stripped and path alias resolved,
// whereas getPathInfo() returns the requested path. In Drupal, the request
// always contains a system_path attribute, but this component may get
// adopted by non-Drupal projects. Some unit tests also skip initializing
// '_system_path'.
// @todo Consider abstracting this to a separate object.
if ($request->attributes->has('_system_path')) {
// _system_path never has leading or trailing slashes.
$path = '/' . $request->attributes->get('_system_path');
}
else {
// getPathInfo() always has leading slash, and might or might not have a
// trailing slash.
$path = rtrim($request->getPathInfo(), '/');
}
$collection = $this->getRoutesByPath($path);
$collection = $this->getRoutesByPath(rtrim($path, '/'));
// Try rebuilding the router if it is necessary.
if (!$collection->count() && $this->routeBuilder->rebuildIfNeeded()) {
......
......@@ -7,6 +7,7 @@
namespace Drupal\Core\Routing;
use Drupal\Core\Path\CurrentPathStack;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Cmf\Component\Routing\NestedMatcher\UrlMatcher as BaseUrlMatcher;
......@@ -16,29 +17,33 @@
*/
class UrlMatcher extends BaseUrlMatcher {
/**
* The current path.
*
* @var \Drupal\Core\Path\CurrentPathStack
*/
protected $currentPath;
/**
* Constructs a new UrlMatcher.
*
* The parent class has a constructor we need to skip, so just override it
* with a no-op.
*
* @param \Drupal\Core\Path\CurrentPathStack $current_path
* The current path.
*/
public function __construct() {}
public function __construct(CurrentPathStack $current_path) {
$this->currentPath = $current_path;
}
public function finalMatch(RouteCollection $collection, Request $request) {
$this->routes = $collection;
$context = new RequestContext();
$context->fromRequest($request);
$this->setContext($context);
if ($request->attributes->has('_system_path')) {
// _system_path never has leading or trailing slashes.
$path = '/' . $request->attributes->get('_system_path');
}
else {
// getPathInfo() always has leading slash, and might or might not have a
// trailing slash.
$path = rtrim($request->getPathInfo(), '/');
}
return $this->match($path);
return $this->match($this->currentPath->getPath($request));
}
}
......@@ -14,6 +14,7 @@
use Drupal\Core\Controller\TitleResolverInterface;
use Drupal\Core\Link;
use Drupal\Core\ParamConverter\ParamNotConvertedException;
use Drupal\Core\Path\CurrentPathStack;
use Drupal\Core\PathProcessor\InboundPathProcessorInterface;
use Drupal\Core\Routing\RequestContext;
use Drupal\Core\Routing\RouteMatch;
......@@ -99,8 +100,10 @@ class PathBasedBreadcrumbBuilder implements BreadcrumbBuilderInterface {
* The title resolver service.
* @param \Drupal\Core\Session\AccountInterface $current_user
* The current user object.
* @param \Drupal\Core\Path\CurrentPathStack $current_path
* The current path.
*/
public function __construct(RequestContext $context, AccessManagerInterface $access_manager, RequestMatcherInterface $router, InboundPathProcessorInterface $path_processor, ConfigFactoryInterface $config_factory, TitleResolverInterface $title_resolver, AccountInterface $current_user) {
public function __construct(RequestContext $context, AccessManagerInterface $access_manager, RequestMatcherInterface $router, InboundPathProcessorInterface $path_processor, ConfigFactoryInterface $config_factory, TitleResolverInterface $title_resolver, AccountInterface $current_user, CurrentPathStack $current_path) {
$this->context = $context;
$this->accessManager = $access_manager;
$this->router = $router;
......@@ -108,6 +111,7 @@ public function __construct(RequestContext $context, AccessManagerInterface $acc
$this->config = $config_factory->get('system.site');
$this->titleResolver = $title_resolver;
$this->currentUser = $current_user;
$this->currentPath = $current_path;
}
/**
......@@ -191,7 +195,7 @@ protected function getRequestForPath($path, array $exclude) {
// This resolves to the front page, which we already add.
return NULL;
}
$request->attributes->set('_system_path', $processed);
$this->currentPath->setPath('/' . $processed, $request);
// Attempt to match this path to provide a fully built request.
try {
$request->attributes->add($this->router->matchRequest($request));
......
......@@ -11,6 +11,7 @@
use Drupal\Core\Condition\ConditionPluginBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Path\AliasManagerInterface;
use Drupal\Core\Path\CurrentPathStack;
use Drupal\Core\Path\PathMatcherInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
......@@ -48,6 +49,13 @@ class RequestPath extends ConditionPluginBase implements ContainerFactoryPluginI
*/
protected $requestStack;
/**
* The current path.
*
* @var \Drupal\Core\Path\CurrentPathStack
*/
protected $currentPath;
/**
* Constructs a RequestPath condition plugin.
*
......@@ -57,6 +65,8 @@ class RequestPath extends ConditionPluginBase implements ContainerFactoryPluginI
* The path matcher service.
* @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
* The request stack.
* @param \Drupal\Core\Path\CurrentPathStack $current_path
* The current path.
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
......@@ -64,11 +74,12 @@ class RequestPath extends ConditionPluginBase implements ContainerFactoryPluginI
* @param array $plugin_definition
* The plugin implementation definition.
*/
public function __construct(AliasManagerInterface $alias_manager, PathMatcherInterface $path_matcher, RequestStack $request_stack, array $configuration, $plugin_id, array $plugin_definition) {
public function __construct(AliasManagerInterface $alias_manager, PathMatcherInterface $path_matcher, RequestStack $request_stack, CurrentPathStack $current_path, array $configuration, $plugin_id, array $plugin_definition) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->aliasManager = $alias_manager;
$this->pathMatcher = $path_matcher;
$this->requestStack = $request_stack;
$this->currentPath = $current_path;
}
/**
......@@ -79,6 +90,7 @@ public static function create(ContainerInterface $container, array $configuratio
$container->get('path.alias_manager'),
$container->get('path.matcher'),
$container->get('request_stack'),
$container->get('path.current'),
$configuration,
$plugin_id,
$plugin_definition);
......@@ -141,9 +153,7 @@ public function evaluate() {
$request = $this->requestStack->getCurrentRequest();
// Compare the lowercase path alias (if any) and internal path.
// @todo Remove dependency on the internal _system_path attribute:
// https://www.drupal.org/node/2293581.
$path = $request->attributes->get('_system_path');
$path = trim($this->currentPath->getPath($request), '/');
$path_alias = Unicode::strtolower($this->aliasManager->getAliasByPath($path));
return $this->pathMatcher->matchPath($path_alias, $pages) || (($path != $path_alias) && $this->pathMatcher->matchPath($path, $pages));
......
......@@ -217,6 +217,11 @@ private function formSubmitHelper($form, $edit) {
$form['#token'] = FALSE;
$edit['form_id'] = $form_id;
// Disable page redirect for forms submitted programmatically. This is a
// solution to skip the redirect step (there are no pages, then the redirect
// isn't possible).
$form_state->disableRedirect();
$form_state->setUserInput($edit);
$form_state->setFormObject(new StubForm($form_id, $form));
......
......@@ -7,6 +7,7 @@
namespace Drupal\system\Tests\Plugin\Condition;
use Drupal\Core\Path\CurrentPathStack;
use Drupal\simpletest\KernelTestBase;
use Drupal\system\Tests\Routing\MockAliasManager;
use Symfony\Component\HttpFoundation\Request;
......@@ -48,6 +49,13 @@ class RequestPathTest extends KernelTestBase {
*/
public static $modules = array('system', 'user', 'field', 'path');
/**
* The current path.
*
* @var \Drupal\Core\Path\CurrentPathStack|\PHPUnit_Framework_MockObject_MockObject
*/
protected $currentPath;
/**
* {@inheritdoc}
*/
......@@ -65,6 +73,9 @@ protected function setUp() {
// Set the test request stack in the container.
$this->requestStack = new RequestStack();
$this->container->set('request_stack', $this->requestStack);
$this->currentPath = new CurrentPathStack($this->requestStack);
$this->container->set('path.current', $this->currentPath);
}
/**
......@@ -78,7 +89,6 @@ public function testConditions() {
$pages = "my/pass/page\r\nmy/pass/page2\r\nfoo";
$request = Request::create('/my/pass/page2');
$request->attributes->set('_system_path', 'my/pass/page2');
$this->requestStack->push($request);
/* @var \Drupal\system\Plugin\Condition\RequestPath $condition */
......@@ -91,7 +101,7 @@ public function testConditions() {
$this->assertEqual($condition->summary(), 'Return true on the following pages: my/pass/page, my/pass/page2, foo', 'The condition summary matches for a standard path');
// Test an aliased path.
$request->attributes->set('_system_path', 'my/aliased/page');
$this->currentPath->setPath('/my/aliased/page', $request);
$this->requestStack->pop();
$this->requestStack->push($request);
......@@ -102,7 +112,7 @@ public function testConditions() {
// Test a wildcard path.
$this->aliasManager->addAlias('my/pass/page3', 'my/pass/page3');
$request->attributes->set('_system_path', 'my/pass/page3');
$this->currentPath->setPath('/my/pass/page3', $request);
$this->requestStack->pop();
$this->requestStack->push($request);
......@@ -112,9 +122,9 @@ public function testConditions() {
$this->assertEqual($condition->summary(), 'Return true on the following pages: my/pass/*', 'The condition summary matches for a wildcard path');
// Test a missing path.
$request->attributes->set('_system_path', 'my/fail/page4');
$this->requestStack->pop();
$this->requestStack->push($request);
$this->currentPath->setPath('/my/fail/page4', $request);
$condition->setConfig('pages', 'my/pass/*');
......
......@@ -96,6 +96,20 @@ public function testProcessOutbound() {
$request_stack->push($request);
$request_context->fromRequest($request);
$this->assertEqual('/node/add', \Drupal::url('<current>'));
// Test request without a found route. This happens for example on an
// not found exception page.
$server = [
'SCRIPT_NAME' => '/index.php',
'SCRIPT_FILENAME' => \Drupal::root() . '/index.php',
'SERVER_NAME' => 'http://www.example.com',
];
$request = Request::create('/invalid-path', 'GET', [], [], [], $server);
$request_stack->push($request);
$request_context->fromRequest($request);
// In case we have no routing, the current route should point to the front.
$this->assertEqual('/', \Drupal::url('<current>'));
}
}
......@@ -8,9 +8,11 @@
namespace Drupal\system\Tests\Routing;
use Drupal\Core\KeyValueStore\KeyValueMemoryFactory;
use Drupal\Core\Path\CurrentPathStack;
use Drupal\Core\State\State;
use Drupal\simpletest\KernelTestBase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
......@@ -49,11 +51,19 @@ class RouteProviderTest extends KernelTestBase {
*/
protected $state;
/**
* The current path.
*
* @var \Drupal\Core\Path\CurrentPathStack
*/
protected $currentPath;
protected function setUp() {
parent::setUp();
$this->fixtures = new RoutingFixtures();
$this->routeBuilder = new NullRouteBuilder();
$this->state = new State(new KeyValueMemoryFactory());
$this->currentPath = new CurrentPathStack(new RequestStack());
}
protected function tearDown() {
......@@ -68,7 +78,7 @@ protected function tearDown() {
public function testCandidateOutlines() {
$connection = Database::getConnection();
$provider = new RouteProvider($connection, $this->routeBuilder, $this->state, 'test_routes');
$provider = new RouteProvider($connection, $this->routeBuilder, $this->state, $this->currentPath, 'test_routes');
$parts = array('node', '5', 'edit');
......@@ -91,7 +101,7 @@ public function testCandidateOutlines() {
*/
function testExactPathMatch() {
$connection = Database::getConnection();
$provider = new RouteProvider($connection, $this->routeBuilder, $this->state, 'test_routes');
$provider = new RouteProvider($connection, $this->routeBuilder, $this->state, $this->currentPath, 'test_routes');
$this->fixtures->createTables($connection);
......@@ -115,7 +125,7 @@ function testExactPathMatch() {
*/
function testOutlinePathMatch() {
$connection = Database::getConnection();
$provider = new RouteProvider($connection, $this->routeBuilder, $this->state, 'test_routes');
$provider = new RouteProvider($connection, $this->routeBuilder, $this->state, $this->currentPath, 'test_routes');
$this->fixtures->createTables($connection);
......@@ -144,7 +154,7 @@ function testOutlinePathMatch() {
*/
function testOutlinePathMatchTrailingSlash() {
$connection = Database::getConnection();
$provider = new RouteProvider($connection, $this->routeBuilder, $this->state, 'test_routes');
$provider = new RouteProvider($connection, $this->routeBuilder, $this->state, $this->currentPath, 'test_routes');
$this->fixtures->createTables($connection);
......@@ -173,7 +183,7 @@ function testOutlinePathMatchTrailingSlash() {
*/
function testOutlinePathMatchDefaults() {
$connection = Database::getConnection();
$provider = new RouteProvider($connection, $this->routeBuilder, $this->state, 'test_routes');