Issue #2563801 by rashid_786, sdstyles, keopx, joshi.rohit100, Mile23, lachezar.valchev, NikhilValand: Remove usage of menu_test_theme_page_callback()
parent
7571bfc7fe
commit
17a9dac510
|
@ -52,32 +52,6 @@ function menu_test_menu_local_tasks_alter(&$data, $route_name, RefinableCacheabl
|
|||
$cacheability->addCacheTags(['kittens:dwarf-cat']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue