function HandlerBase::caseTransform
Same name and namespace in other branches
- 11.x core/modules/views/src/Plugin/views/HandlerBase.php \Drupal\views\Plugin\views\HandlerBase::caseTransform()
- 10 core/modules/views/src/Plugin/views/HandlerBase.php \Drupal\views\Plugin\views\HandlerBase::caseTransform()
- 8.9.x core/modules/views/src/Plugin/views/HandlerBase.php \Drupal\views\Plugin\views\HandlerBase::caseTransform()
Transform a string by a certain method.
Parameters
$string: The input you want to transform.
$option: How do you want to transform it, possible values:
- upper: Uppercase the string.
- lower: lowercase the string.
- ucfirst: Make the first char uppercase.
- ucwords: Make each word in the string uppercase.
Return value
string The transformed string.
File
-
core/
modules/ views/ src/ Plugin/ views/ HandlerBase.php, line 236
Class
- HandlerBase
- Base class for Views handler plugins.
Namespace
Drupal\views\Plugin\viewsCode
protected function caseTransform($string, $option) {
switch ($option) {
default:
return $string;
case 'upper':
return mb_strtoupper($string);
case 'lower':
return mb_strtolower($string);
case 'ucfirst':
return Unicode::ucfirst($string);
case 'ucwords':
return Unicode::ucwords($string);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.