trait HighContrastTrait in High contrast 8
This is an abstraction wrapper for controlling high contrast.
This class is provided to allow abstraction of the detection and setting of high contrast mode. Currently it is configured to use the session, but this allows for easier change if that may be required at some point.
Hierarchy
- trait \Drupal\high_contrast\HighContrastTrait
4 files declare their use of HighContrastTrait
- HighContrastCacheContext.php in src/
Cache/ Context/ HighContrastCacheContext.php - HighContrastStyleSheetTest.php in tests/
src/ FunctionalJavascript/ HighContrastStyleSheetTest.php - HighContrastSwitchForm.php in src/
Form/ HighContrastSwitchForm.php - high_contrast.module in ./
high_contrast.module - Allows users to switch to a high contrast version of the active theme.
File
- src/
HighContrastTrait.php, line 12
Namespace
Drupal\high_contrastView source
trait HighContrastTrait {
/**
* Return if high contrast is enabled or not.
*
* @return bool
* TRUE if enabled, FALSE otherwise.
*/
public static function highContrastEnabled() {
return !empty($_SESSION['high_contrast']['enabled']) ? TRUE : FALSE;
}
/**
* Enables high contrast mode.
*/
public function enableHighContrast() {
$_SESSION['high_contrast']['enabled'] = TRUE;
}
/**
* Disables high contrast mode.
*/
public function disableHighContrast() {
$_SESSION['high_contrast']['enabled'] = FALSE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
HighContrastTrait:: |
public | function | Disables high contrast mode. | |
HighContrastTrait:: |
public | function | Enables high contrast mode. | |
HighContrastTrait:: |
public static | function | Return if high contrast is enabled or not. |