Commit 469fe97e authored by webchick's avatar webchick

Issue #2329303 by tim.plunkett, dawehner: Fixed Use the right request when...

Issue #2329303 by tim.plunkett, dawehner: Fixed Use the right request when determining the theme on a 403 page.
parent 2191f864
......@@ -13,7 +13,7 @@
/**
* Default object for current_route_match service.
*/
class CurrentRouteMatch implements RouteMatchInterface {
class CurrentRouteMatch implements RouteMatchInterface, StackedRouteMatchInterface {
/**
* The related request stack.
......@@ -88,7 +88,7 @@ public function getRawParameters() {
* @return \Drupal\Core\Routing\RouteMatchInterface
* The current route match object.
*/
protected function getCurrentRouteMatch() {
public function getCurrentRouteMatch() {
return $this->getRouteMatch($this->requestStack->getCurrentRequest());
}
......@@ -118,4 +118,18 @@ protected function getRouteMatch(Request $request) {
return $route_match;
}
/**
* {@inheritdoc}
*/
public function getMasterRouteMatch() {
return $this->getRouteMatch($this->requestStack->getMasterRequest());
}
/**
* {@inheritdoc}
*/
public function getParentRouteMatch() {
return $this->getRouteMatch($this->requestStack->getParentRequest());
}
}
<?php
/**
* @file
* Contains \Drupal\Core\Routing\StackedRouteMatchInterface.
*/
namespace Drupal\Core\Routing;
/**
* Defines an interface for a stack of route matches.
*
* This could be for example used on exception pages.
*/
interface StackedRouteMatchInterface extends RouteMatchInterface {
/**
* Gets the current route match.
*
* @return \Drupal\Core\Routing\RouteMatchInterface
*/
public function getCurrentRouteMatch();
/**
* Gets the master route match..
*
* @return \Drupal\Core\Routing\RouteMatchInterface
*/
public function getMasterRouteMatch();
/**
* Returns the parent route match of the current.
*
* @return \Drupal\Core\Routing\RouteMatchInterface\NULL
* The parent route match or NULL, if it the master route match.
*/
public function getParentRouteMatch();
}
......@@ -9,6 +9,7 @@
use Drupal\Core\Extension\ThemeHandlerInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Routing\StackedRouteMatchInterface;
use Symfony\Component\HttpFoundation\RequestStack;
/**
......@@ -124,6 +125,9 @@ protected function initTheme(RouteMatchInterface $route_match = NULL) {
if (!$route_match) {
$route_match = \Drupal::routeMatch();
}
if ($route_match instanceof StackedRouteMatchInterface) {
$route_match = $route_match->getMasterRouteMatch();
}
$theme = $this->themeNegotiator->determineActiveTheme($route_match);
$this->activeTheme = $this->themeInitialization->initTheme($theme);
}
......
......@@ -209,6 +209,14 @@ function testAdministrationTheme() {
$this->drupalGet('admin/config');
$this->assertRaw('core/themes/seven', 'Administration theme used on an administration page.');
// Ensure that the admin theme is also visible on the 403 page.
$normal_user = $this->drupalCreateUser(['view the administration theme']);
$this->drupalLogin($normal_user);
$this->drupalGet('admin/config');
$this->assertResponse(403);
$this->assertRaw('core/themes/seven', 'Administration theme used on an administration page.');
$this->drupalLogin($this->admin_user);
$this->drupalGet('node/add');
$this->assertRaw('core/themes/stark', 'Site default theme used on the add content page.');
......
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