class TestThemeNegotiator

Same name in other branches
  1. 9 core/modules/system/tests/modules/menu_test/src/Theme/TestThemeNegotiator.php \Drupal\menu_test\Theme\TestThemeNegotiator
  2. 10 core/modules/system/tests/modules/menu_test/src/Theme/TestThemeNegotiator.php \Drupal\menu_test\Theme\TestThemeNegotiator
  3. 11.x core/modules/system/tests/modules/menu_test/src/Theme/TestThemeNegotiator.php \Drupal\menu_test\Theme\TestThemeNegotiator

Tests the theme negotiation functionality.

Retrieves the theme key of the theme to use for the current request based on the theme name provided in the URL.

Hierarchy

Expanded class hierarchy of TestThemeNegotiator

1 string reference to 'TestThemeNegotiator'
menu_test.services.yml in core/modules/system/tests/modules/menu_test/menu_test.services.yml
core/modules/system/tests/modules/menu_test/menu_test.services.yml
1 service uses TestThemeNegotiator
theme.negotiator.test_theme in core/modules/system/tests/modules/menu_test/menu_test.services.yml
Drupal\menu_test\Theme\TestThemeNegotiator

File

core/modules/system/tests/modules/menu_test/src/Theme/TestThemeNegotiator.php, line 14

Namespace

Drupal\menu_test\Theme
View source
class TestThemeNegotiator implements ThemeNegotiatorInterface {
    
    /**
     * {@inheritdoc}
     */
    public function applies(RouteMatchInterface $route_match) {
        return (bool) $route_match->getParameter('inherited');
    }
    
    /**
     * {@inheritdoc}
     */
    public function determineActiveTheme(RouteMatchInterface $route_match) {
        $argument = $route_match->getParameter('inherited');
        // Test using the variable administrative theme.
        if ($argument == 'use-admin-theme') {
            return \Drupal::config('system.theme')->get('admin');
        }
        elseif ($argument == 'use-test-theme') {
            return 'test_theme';
        }
        elseif ($argument == 'use-fake-theme') {
            return 'fake_theme';
        }
        // For any other value of the URL argument, do not return anything. This
        // allows us to test that returning nothing from a theme negotiation
        // causes the page to correctly fall back on using the main site theme.
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
TestThemeNegotiator::applies public function Whether this theme negotiator should be used to set the theme. Overrides ThemeNegotiatorInterface::applies
TestThemeNegotiator::determineActiveTheme public function Determine the active theme for the request. Overrides ThemeNegotiatorInterface::determineActiveTheme

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.