function Depth::getItems

Same name in other branches
  1. 9 core/modules/comment/src/Plugin/views/field/Depth.php \Drupal\comment\Plugin\views\field\Depth::getItems()
  2. 10 core/modules/comment/src/Plugin/views/field/Depth.php \Drupal\comment\Plugin\views\field\Depth::getItems()
  3. 11.x core/modules/comment/src/Plugin/views/field/Depth.php \Drupal\comment\Plugin\views\field\Depth::getItems()

Overrides EntityField::getItems

File

core/modules/comment/src/Plugin/views/field/Depth.php, line 20

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.