Created
September 18, 2017 19:12
-
-
Save jackbravo/18ad4061e9f280201d59367ae734b55e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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