You are here

public function Grid::getCustomClass in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views/src/Plugin/views/style/Grid.php \Drupal\views\Plugin\views\style\Grid::getCustomClass()

Return the token-replaced row or column classes for the specified result.

Parameters

int $result_index: The delta of the result item to get custom classes for.

string $type: The type of custom grid class to return, either "row" or "col".

Return value

string A space-delimited string of classes.

File

core/modules/views/src/Plugin/views/style/Grid.php, line 111

Class

Grid
Style plugin to render each item in a grid cell.

Namespace

Drupal\views\Plugin\views\style

Code

public function getCustomClass($result_index, $type) {
  $class = $this->options[$type . '_class_custom'];
  if ($this
    ->usesFields() && $this->view->field) {
    $class = strip_tags($this
      ->tokenizeValue($class, $result_index));
  }
  $classes = explode(' ', $class);
  foreach ($classes as &$class) {
    $class = Html::cleanCssIdentifier($class);
  }
  return implode(' ', $classes);
}