function _styleswitcher_style_name in Style Switcher 8.2
Same name and namespace in other branches
- 6.2 styleswitcher.module \_styleswitcher_style_name()
- 7.2 styleswitcher.module \_styleswitcher_style_name()
- 3.0.x styleswitcher.module \_styleswitcher_style_name()
Transliterates a human-readable name to a machine name.
Parameters
string $display_name: Style label.
Return value
string Transliterated name.
See also
Drupal.behaviors.machineName.transliterate()
\Drupal\Component\Utility\Html::cleanCssIdentifier()
\Drupal\Component\Utility\Html::getId()
2 calls to _styleswitcher_style_name()
- DefaultController::activeStylePath in src/
Controller/ DefaultController.php - Finds the style active for current user and returns its path.
- styleswitcher_theme_styles in ./
styleswitcher.module - Returns a list of styles provided by a theme.
File
- ./
styleswitcher.module, line 363 - Module's hooks implementations and helper functions.
Code
function _styleswitcher_style_name($display_name) {
$name = mb_strtolower($display_name);
$name = strtr($name, [
' ' => '_',
'-' => '_',
]);
$name = preg_replace('/[^a-z0-9_]/', '', $name);
return $name;
}