Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / system / tests / modules / menu_test / src / Theme / TestThemeNegotiator.php
1 <?php
2
3 namespace Drupal\menu_test\Theme;
4
5 use Drupal\Core\Routing\RouteMatchInterface;
6 use Drupal\Core\Theme\ThemeNegotiatorInterface;
7
8 /**
9  * Tests the theme negotiation functionality.
10  *
11  * Retrieves the theme key of the theme to use for the current request based on
12  * the theme name provided in the URL.
13  */
14 class TestThemeNegotiator implements ThemeNegotiatorInterface {
15
16   /**
17    * {@inheritdoc}
18    */
19   public function applies(RouteMatchInterface $route_match) {
20     return (bool) $route_match->getParameter('inherited');
21   }
22
23   /**
24    * {@inheritdoc}
25    */
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');
31     }
32     // Test using a theme that exists, but may or may not be installed.
33     elseif ($argument == 'use-test-theme') {
34       return 'test_theme';
35     }
36     // Test using a theme that does not exist.
37     elseif ($argument == 'use-fake-theme') {
38       return 'fake_theme';
39     }
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.
43   }
44
45 }