ThemeKeyNegotiator.php in ThemeKey 8
File
src/Theme/ThemeKeyNegotiator.php
View source
<?php
namespace Drupal\themekey\Theme;
use Drupal\Core\Theme\ThemeNegotiatorInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\themekey\EngineInterface;
class ThemeKeyNegotiator implements ThemeNegotiatorInterface {
protected $themeKeyEngine;
protected function getThemeKeyEngine() {
if (!$this->themeKeyEngine) {
$this->themeKeyEngine = \Drupal::service('themekey.engine');
}
return $this->themeKeyEngine;
}
public function setThemeKeyEngine(EngineInterface $themeKeyEngine) {
$this->themeKeyEngine = $themeKeyEngine;
return $this;
}
public function applies(RouteMatchInterface $route_match) {
if (strpos($route_match
->getRouteName(), 'themekey_rule.') === 0) {
return FALSE;
}
return TRUE;
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;
}
public function determineActiveTheme(RouteMatchInterface $route_match) {
return $this
->getThemeKeyEngine()
->determineTheme($route_match);
}
}