Skip to content

Instantly share code, notes, and snippets.

@jackbravo
Created September 18, 2017 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jackbravo/18ad4061e9f280201d59367ae734b55e to your computer and use it in GitHub Desktop.
Save jackbravo/18ad4061e9f280201d59367ae734b55e to your computer and use it in GitHub Desktop.
<?php
namespace Drupal\custom_theme_helpers;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Theme\ThemeNegotiatorInterface;
/**
* Class CustomThemeNegotiator.
*
* @package Drupal\bixal_theme_helpers
*/
class CustomThemeNegotiator implements ThemeNegotiatorInterface {
/**
* Whether this theme negotiator should be used to set the theme.
*
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The current route match object.
*
* @return bool
* TRUE if this negotiator should be used or FALSE to let other negotiators
* decide.
*/
public function applies(RouteMatchInterface $route_match) {
return \Drupal::service('path.matcher')->isFrontPage();
}
/**
* Determine the active theme for the request.
*
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The current route match object.
*
* @return string|null
* The name of the theme, or NULL if other negotiators, like the configured
* default one, should be used instead.
*/
public function determineActiveTheme(RouteMatchInterface $route_match) {
return 'custom_theme';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment