class Depth

Same name and namespace in other branches
  1. 11.x core/modules/comment/src/Plugin/views/field/Depth.php \Drupal\comment\Plugin\views\field\Depth

Field handler to display the depth of a comment.

Plugin annotation

@ViewsField("comment_depth");

Hierarchy

Expanded class hierarchy of Depth

Related topics

20 string references to 'Depth'
Book::query in core/modules/book/src/Plugin/migrate/source/Book.php
BookOutlineStorage::getBookMenuTree in core/modules/book/src/BookOutlineStorage.php
BookOutlineStorage::getChildRelativeDepth in core/modules/book/src/BookOutlineStorage.php
BookOutlineStorage::updateMovedChildren in core/modules/book/src/BookOutlineStorage.php
book_views_data in core/modules/book/book.views.inc
Implements hook_views_data().

... See full list

File

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

Namespace

Drupal\comment\Plugin\views\field
View source
class Depth extends EntityField {
  
  /**
   * {@inheritdoc}
   */
  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;
  }

}

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