function ViewsThemeHooks::preprocessComment

Same name and namespace in other branches
  1. 11.x core/modules/views/src/Hook/ViewsThemeHooks.php \Drupal\views\Hook\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 220

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;
    // The view variable is deprecated.
    $variables['deprecations']['view'] = "'view' is deprecated in drupal:11.3.0 and is removed in drupal:13.0.0. There is no replacement. See https://www.drupal.org/node/3541463";
  }
}

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