You are here

public function PlainStringFormatter::prepareClasses in String field formatter 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/Field/FieldFormatter/PlainStringFormatter.php \Drupal\string_field_formatter\Plugin\Field\FieldFormatter\PlainStringFormatter::prepareClasses()

Build classes.

2 calls to PlainStringFormatter::prepareClasses()
PlainStringFormatter::settingsSummary in src/Plugin/Field/FieldFormatter/PlainStringFormatter.php
Returns a short summary for the current formatter settings.
PlainStringFormatter::viewElements in src/Plugin/Field/FieldFormatter/PlainStringFormatter.php
Builds a renderable array for a field value.

File

src/Plugin/Field/FieldFormatter/PlainStringFormatter.php, line 109

Class

PlainStringFormatter
Plugin implementation of the 'plain_string_formatter' formatter.

Namespace

Drupal\string_field_formatter\Plugin\Field\FieldFormatter

Code

public function prepareClasses($class) {
  $class = preg_replace('! !', ',', $class);
  $all = explode(',', $class);
  $prepared = [];
  foreach ($all as $c) {
    $c = trim($c);
    if ($c) {
      $prepared[] = Html::getClass($c);
    }
  }
  return $prepared;
}