class ThemeNegotiator in Visually Impaired Support (module) 8
Defines the theme negotiator.
Hierarchy
- class \Drupal\visually_impaired_module\Theme\ThemeNegotiator implements ThemeNegotiatorInterface
Expanded class hierarchy of ThemeNegotiator
1 string reference to 'ThemeNegotiator'
1 service uses ThemeNegotiator
File
- src/
Theme/ ThemeNegotiator.php, line 13
Namespace
Drupal\visually_impaired_module\ThemeView source
class ThemeNegotiator implements ThemeNegotiatorInterface {
/**
* Config factory.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;
/**
* Route Admin Context.
*
* @var \Drupal\Core\Routing\AdminContext
*/
protected $routerAdminContext;
/**
* ThemeNegotiator constructor.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
*
* The Config Factory.
* @param \Drupal\Core\Routing\AdminContext $router_admin_context
*
* The Router Admin Context.
*/
public function __construct(ConfigFactoryInterface $config_factory, AdminContext $router_admin_context) {
$this->configFactory = $config_factory;
$this->routerAdminContext = $router_admin_context;
}
/**
* {@inheritdoc}
*/
public function applies(RouteMatchInterface $route_match) {
return TRUE;
}
/**
* {@inheritdoc}
*/
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');
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ThemeNegotiator:: |
protected | property | Config factory. | |
ThemeNegotiator:: |
protected | property | Route Admin Context. | |
ThemeNegotiator:: |
public | function |
Whether this theme negotiator should be used to set the theme. Overrides ThemeNegotiatorInterface:: |
|
ThemeNegotiator:: |
public | function |
Determine the active theme for the request. Overrides ThemeNegotiatorInterface:: |
|
ThemeNegotiator:: |
public | function | ThemeNegotiator constructor. |