You are here

protected function HandlerBase::caseTransform in Drupal 8

Same name and namespace in other branches
  1. 9 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.

5 calls to HandlerBase::caseTransform()
FieldPluginBase::renderAsLink in core/modules/views/src/Plugin/views/field/FieldPluginBase.php
Render this field as a link, with the info from a fieldset set by the user.
StringArgument::summaryArgument in core/modules/views/src/Plugin/views/argument/StringArgument.php
Provide the argument to use to link from the summary to the next level; this will be called once per row of a summary, and used as part of $view->getUrl().
StringArgument::summaryName in core/modules/views/src/Plugin/views/argument/StringArgument.php
Provides the name to use for the summary. By default this is just the name field.
StringArgument::title in core/modules/views/src/Plugin/views/argument/StringArgument.php
Get the title this argument will assign the view, given the argument.
StringListField::summaryName in core/modules/options/src/Plugin/views/argument/StringListField.php
Provides the name to use for the summary. By default this is just the name field.

File

core/modules/views/src/Plugin/views/HandlerBase.php, line 231

Class

HandlerBase
Base class for Views handler plugins.

Namespace

Drupal\views\Plugin\views

Code

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);
  }
}