summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2015-09-30 15:02:15 +0100
committerAlex Pott2015-09-30 15:03:44 +0100
commit17a9dac510013594ad5e51c655c4ea90c0210f8c (patch)
treed7f70e6212023d16ea1ef1186fbcfdf05eed75b4
parent7571bfc7fe5b3dfdf1091b7d64a93cf8ee7dca76 (diff)
Issue #2563801 by rashid_786, sdstyles, keopx, joshi.rohit100, Mile23, lachezar.valchev, NikhilValand: Remove usage of menu_test_theme_page_callback()
-rw-r--r--core/modules/system/tests/modules/menu_test/menu_test.module26
-rw-r--r--core/modules/system/tests/modules/menu_test/src/Controller/MenuTestController.php77
2 files changed, 74 insertions, 29 deletions
diff --git a/core/modules/system/tests/modules/menu_test/menu_test.module b/core/modules/system/tests/modules/menu_test/menu_test.module
index cf259df..093f3b8 100644
--- a/core/modules/system/tests/modules/menu_test/menu_test.module
+++ b/core/modules/system/tests/modules/menu_test/menu_test.module
@@ -53,32 +53,6 @@ function menu_test_menu_local_tasks_alter(&$data, $route_name, RefinableCacheabl
}
/**
- * Page callback: Tests the theme negotiation functionality.
- *
- * @param bool $inherited
- * (optional) TRUE when the requested page is intended to inherit
- * the theme of its parent.
- *
- * @return string
- * A string describing the requested custom theme and actual theme being used
- * for the current page request.
- *
- * @see menu_test_menu().
- *
- * @deprecated Use \Drupal\menu_test\Controller\MenuTestController::themePage()
- */
-function menu_test_theme_page_callback($inherited = FALSE) {
- $theme_key = \Drupal::theme()->getActiveTheme()->getName();
- // Now we check what the theme negotiator service returns.
- $active_theme = \Drupal::service('theme.negotiator')->determineActiveTheme(\Drupal::routeMatch());
- $output = "Active theme: $active_theme. Actual theme: $theme_key.";
- if ($inherited) {
- $output .= ' Theme negotiation inheritance is being tested.';
- }
- return ['#markup' => $output];
-}
-
-/**
* Sets a static variable for the testMenuName() test.
*
* Used to change the menu_name parameter of a menu.
diff --git a/core/modules/system/tests/modules/menu_test/src/Controller/MenuTestController.php b/core/modules/system/tests/modules/menu_test/src/Controller/MenuTestController.php
index eb7bec5..c5088e8 100644
--- a/core/modules/system/tests/modules/menu_test/src/Controller/MenuTestController.php
+++ b/core/modules/system/tests/modules/menu_test/src/Controller/MenuTestController.php
@@ -7,10 +7,64 @@
namespace Drupal\menu_test\Controller;
+use Drupal\Core\Controller\ControllerBase;
+use Drupal\Core\Routing\RouteMatchInterface;
+use Drupal\Core\Theme\ThemeManagerInterface;
+use Drupal\Core\Theme\ThemeNegotiatorInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
/**
* Controller routines for menu_test routes.
*/
-class MenuTestController {
+class MenuTestController extends ControllerBase {
+
+ /**
+ * The theme manager.
+ *
+ * @var \Drupal\Core\Theme\ThemeManagerInterface
+ */
+ protected $themeManager;
+
+ /**
+ * The theme negotiator.
+ *
+ * @var \Drupal\Core\Theme\ThemeNegotiatorInterface
+ */
+ protected $themeNegotiator;
+
+ /**
+ * The active route match.
+ *
+ * @var \Drupal\Core\Routing\RouteMatchInterface
+ */
+ protected $routeMatch;
+
+ /**
+ * Constructs the MenuTestController object.
+ *
+ * @param \Drupal\menu_test\Controller\ThemeManagerInterface $theme_manager
+ * The theme manager.
+ * @param \Drupal\menu_test\Controller\ThemeNegotiatorInterface $theme_negotiator
+ * The theme negotiator.
+ * @param \Drupal\menu_test\Controller\RouteMatchInterface $route_match
+ * The current route match.
+ */
+ public function __construct(ThemeManagerInterface $theme_manager, ThemeNegotiatorInterface $theme_negotiator, RouteMatchInterface $route_match) {
+ $this->themeManager = $theme_manager;
+ $this->themeNegotiator = $theme_negotiator;
+ $this->routeMatch = $route_match;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function create(ContainerInterface $container) {
+ return new static(
+ $container->get('theme.manager'),
+ $container->get('theme.negotiator'),
+ $container->get('current_route_match')
+ );
+ }
/**
* Some known placeholder content which can be used for testing.
@@ -40,10 +94,27 @@ class MenuTestController {
}
/**
- * @todo Remove menu_test_theme_page_callback().
+ * Page callback: Tests the theme negotiation functionality.
+ *
+ * @param bool $inherited
+ * TRUE when the requested page is intended to inherit
+ * the theme of its parent.
+ *
+ * @return string
+ * A string describing the requested custom theme and actual
+ * theme being used
+ * for the current page request.
*/
public function themePage($inherited) {
- return menu_test_theme_page_callback($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];
}
/**