3 namespace Drupal\menu_test\Theme;
5 use Drupal\Core\Routing\RouteMatchInterface;
6 use Drupal\Core\Theme\ThemeNegotiatorInterface;
9 * Tests the theme negotiation functionality.
11 * Retrieves the theme key of the theme to use for the current request based on
12 * the theme name provided in the URL.
14 class TestThemeNegotiator implements ThemeNegotiatorInterface {
19 public function applies(RouteMatchInterface $route_match) {
20 return (bool) $route_match->getParameter('inherited');
26 public function determineActiveTheme(RouteMatchInterface $route_match) {
27 $argument = $route_match->getParameter('inherited');
28 // Test using the variable administrative theme.
29 if ($argument == 'use-admin-theme') {
30 return \Drupal::config('system.theme')->get('admin');
32 // Test using a theme that exists, but may or may not be installed.
33 elseif ($argument == 'use-test-theme') {
36 // Test using a theme that does not exist.
37 elseif ($argument == 'use-fake-theme') {
40 // For any other value of the URL argument, do not return anything. This
41 // allows us to test that returning nothing from a theme negotiation
42 // causes the page to correctly fall back on using the main site theme.