Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Depth.php

function 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']['#context']['value'];
        $item['rendered']['#context']['value'] = count(explode('.', $comment_thread)) - 1;
    }
    return $items;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal