You are here

public function ThemeKeyNegotiator::applies in ThemeKey 8

Whether this theme negotiator should be used to set the theme.

Parameters

\Drupal\Core\Routing\RouteMatchInterface $route_match: The current route match object.

Return value

bool TRUE if this negotiator should be used or FALSE to let other negotiators decide.

Overrides ThemeNegotiatorInterface::applies

File

src/Theme/ThemeKeyNegotiator.php, line 53

Class

ThemeKeyNegotiator

Namespace

Drupal\themekey\Theme

Code

public function applies(RouteMatchInterface $route_match) {
  if (strpos($route_match
    ->getRouteName(), 'themekey_rule.') === 0) {
    return FALSE;
  }
  return TRUE;

  // TODO migrate complete function themekey_is_active() to applies()
  // Don't change theme when ...
  if ((in_array('system', variable_get('themekey_compat_modules_enabled', array())) || !(variable_get('admin_theme', '0') && path_is_admin($_GET['q']))) && strpos($_GET['q'], 'admin/structure/block/demo') !== 0 && strpos($_SERVER['SCRIPT_FILENAME'], 'cron.php') === FALSE && strpos($_SERVER['SCRIPT_FILENAME'], 'drush.php') === FALSE && (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'install' && MAINTENANCE_MODE != 'update')) {
    require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'themekey') . '/themekey_base.inc';
    $paths = $paths = array_merge_recursive(themekey_invoke_modules('themekey_disabled_paths'), module_invoke_all('themekey_disabled_paths'));
    foreach ($paths as $path) {
      if (strpos($_GET['q'], $path) === 0) {
        return FALSE;
      }
    }
    return TRUE;
  }
  return FALSE;
}