function ViewsThemeHooks::preprocessComment

Implements hook_preprocess_HOOK().

Allows view-based comment templates if called from a view.

Attributes

#[Hook('preprocess_comment')]

File

core/modules/views/src/Hook/ViewsThemeHooks.php, line 45

Class

ViewsThemeHooks
Hook implementations for views.

Namespace

Drupal\views\Hook

Code

public function preprocessComment(&$variables) : void {
  // The view data is added to the comment in
  // \Drupal\views\Plugin\views\row\EntityRow::preRender().
  if (!empty($variables['comment']->view) && $variables['comment']->view->storage
    ->id()) {
    $variables['view'] = $variables['comment']->view;
  }
}

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