ThemeNegotiator.php in Visually Impaired Support (module) 8
File
src/Theme/ThemeNegotiator.php
View source
<?php
namespace Drupal\visually_impaired_module\Theme;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Theme\ThemeNegotiatorInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Routing\AdminContext;
class ThemeNegotiator implements ThemeNegotiatorInterface {
protected $configFactory;
protected $routerAdminContext;
public function __construct(ConfigFactoryInterface $config_factory, AdminContext $router_admin_context) {
$this->configFactory = $config_factory;
$this->routerAdminContext = $router_admin_context;
}
public function applies(RouteMatchInterface $route_match) {
return TRUE;
}
public function determineActiveTheme(RouteMatchInterface $route_match) {
$config = $this->configFactory
->get('visually_impaired_module.visually_impaired_module.settings');
$is_admin = $this->routerAdminContext
->isAdminRoute($route_match
->getRouteObject());
if (isset($_COOKIE['visually_impaired']) && $_COOKIE['visually_impaired'] == 'on' && $is_admin == FALSE) {
return $config
->get('visually_impaired_theme');
}
}
}