function MenuTestController::themePage

Same name in other branches
  1. 8.9.x core/modules/system/tests/modules/menu_test/src/Controller/MenuTestController.php \Drupal\menu_test\Controller\MenuTestController::themePage()
  2. 10 core/modules/system/tests/modules/menu_test/src/Controller/MenuTestController.php \Drupal\menu_test\Controller\MenuTestController::themePage()
  3. 11.x core/modules/system/tests/modules/menu_test/src/Controller/MenuTestController.php \Drupal\menu_test\Controller\MenuTestController::themePage()

Page callback: Tests the theme negotiation functionality.

Parameters

bool $inherited: TRUE when the requested page is intended to inherit the theme of its parent.

Return value

string A string describing the requested custom theme and actual theme being used for the current page request.

1 string reference to 'MenuTestController::themePage'
menu_test.routing.yml in core/modules/system/tests/modules/menu_test/menu_test.routing.yml
core/modules/system/tests/modules/menu_test/menu_test.routing.yml

File

core/modules/system/tests/modules/menu_test/src/Controller/MenuTestController.php, line 102

Class

MenuTestController
Controller routines for menu_test routes.

Namespace

Drupal\menu_test\Controller

Code

public function themePage($inherited) {
    $theme_key = $this->themeManager
        ->getActiveTheme()
        ->getName();
    // Now we check what the theme negotiator service returns.
    $active_theme = $this->themeNegotiator
        ->determineActiveTheme($this->routeMatch);
    $output = "Active theme: {$active_theme}. Actual theme: {$theme_key}.";
    if ($inherited) {
        $output .= ' Theme negotiation inheritance is being tested.';
    }
    return [
        '#markup' => $output,
    ];
}

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