CustomThemeNegotiator.php

Same filename in other branches
  1. 8.9.x core/modules/system/tests/modules/theme_test/src/Theme/CustomThemeNegotiator.php
  2. 10 core/modules/system/tests/modules/theme_test/src/Theme/CustomThemeNegotiator.php
  3. 11.x core/modules/system/tests/modules/theme_test/src/Theme/CustomThemeNegotiator.php

Namespace

Drupal\theme_test\Theme

File

core/modules/system/tests/modules/theme_test/src/Theme/CustomThemeNegotiator.php

View source
<?php

namespace Drupal\theme_test\Theme;

use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Theme\ThemeNegotiatorInterface;

/**
 * Just forces the 'test_theme' theme.
 */
class CustomThemeNegotiator implements ThemeNegotiatorInterface {
    
    /**
     * {@inheritdoc}
     */
    public function applies(RouteMatchInterface $route_match) {
        $route = $route_match->getRouteObject();
        return $route && $route->hasOption('_custom_theme');
    }
    
    /**
     * {@inheritdoc}
     */
    public function determineActiveTheme(RouteMatchInterface $route_match) {
        return $route_match->getRouteObject()
            ->getOption('_custom_theme');
    }

}

Classes

Title Deprecated Summary
CustomThemeNegotiator Just forces the 'test_theme' theme.

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