Version 1
[yaffs-website] / web / core / modules / system / tests / modules / theme_test / src / Theme / CustomThemeNegotiator.php
diff --git a/web/core/modules/system/tests/modules/theme_test/src/Theme/CustomThemeNegotiator.php b/web/core/modules/system/tests/modules/theme_test/src/Theme/CustomThemeNegotiator.php
new file mode 100644 (file)
index 0000000..727e3b7
--- /dev/null
@@ -0,0 +1,28 @@
+<?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');
+  }
+
+}