protected function 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 drupal/core/modules/views/lib/Drupal/views/Plugin/views/field/FieldPluginBase.php
Render this field as a link, with the info from a fieldset set by the user.
ListString::summaryName in drupal/core/modules/field/lib/Drupal/field/Plugin/views/argument/ListString.php
Provides the name to use for the summary. By default this is just the name field.
String::summaryArgument in drupal/core/modules/views/lib/Drupal/views/Plugin/views/argument/String.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().
String::summaryName in drupal/core/modules/views/lib/Drupal/views/Plugin/views/argument/String.php
Provides the name to use for the summary. By default this is just the name field.
String::title in drupal/core/modules/views/lib/Drupal/views/Plugin/views/argument/String.php
Get the title this argument will assign the view, given the argument.

File

drupal/core/modules/views/lib/Drupal/views/Plugin/views/HandlerBase.php, line 245
Definition of Drupal\views\Plugin\views\HandlerBase.

Class

HandlerBase

Namespace

Drupal\views\Plugin\views

Code

protected function caseTransform($string, $option) {
  switch ($option) {
    default:
      return $string;
    case 'upper':
      return drupal_strtoupper($string);
    case 'lower':
      return drupal_strtolower($string);
    case 'ucfirst':
      return drupal_strtoupper(drupal_substr($string, 0, 1)) . drupal_substr($string, 1);
    case 'ucwords':
      if (Unicode::getStatus() == Unicode::STATUS_MULTIBYTE) {
        return mb_convert_case($string, MB_CASE_TITLE);
      }
      else {
        return ucwords($string);
      }
  }
}