You are here

public function Depth::getItems in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/comment/src/Plugin/views/field/Depth.php \Drupal\comment\Plugin\views\field\Depth::getItems()

Gets an array of items for the field.

Parameters

\Drupal\views\ResultRow $values: The result row object containing the values.

Return value

array An array of items for the field.

Overrides Field::getItems

File

core/modules/comment/src/Plugin/views/field/Depth.php, line 25
Contains \Drupal\comment\Plugin\views\field\Depth.

Class

Depth
Field handler to display the depth of a comment.

Namespace

Drupal\comment\Plugin\views\field

Code

public function getItems(ResultRow $values) {
  $items = parent::getItems($values);
  foreach ($items as &$item) {

    // Work out the depth of this comment.
    $comment_thread = $item['rendered']['#markup'];
    $item['rendered']['#markup'] = count(explode('.', $comment_thread)) - 1;
  }
  return $items;
}