public function Depth::getItems in Drupal 10
Same name and namespace in other branches
- 8 core/modules/comment/src/Plugin/views/field/Depth.php \Drupal\comment\Plugin\views\field\Depth::getItems()
- 9 core/modules/comment/src/Plugin/views/field/Depth.php \Drupal\comment\Plugin\views\field\Depth::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\fieldCode
public function getItems(ResultRow $values) {
$items = parent::getItems($values);
foreach ($items as &$item) {
// Work out the depth of this comment.
$comment_thread = $item['rendered']['#context']['value'];
$item['rendered']['#context']['value'] = count(explode('.', $comment_thread)) - 1;
}
return $items;
}