3 namespace Drupal\comment\Plugin\views\field;
5 use Drupal\views\Plugin\views\field\EntityField;
6 use Drupal\views\ResultRow;
9 * Field handler to display the depth of a comment.
11 * @ingroup views_field_handlers
13 * @ViewsField("comment_depth")
15 class Depth extends EntityField {
20 public function getItems(ResultRow $values) {
21 $items = parent::getItems($values);
23 foreach ($items as &$item) {
24 // Work out the depth of this comment.
25 $comment_thread = $item['rendered']['#markup'];
26 $item['rendered']['#markup'] = count(explode('.', $comment_thread)) - 1;