You are here

public function FieldPluginBase::theme in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views/src/Plugin/views/field/FieldPluginBase.php \Drupal\views\Plugin\views\field\FieldPluginBase::theme()

Passes values to drupal_render() using $this->themeFunctions() as #theme.

Parameters

\Drupal\views\ResultRow $values: Holds single row of a view's result set.

Return value

string|\Drupal\Component\Render\MarkupInterface Returns rendered output of the given theme implementation. If the output is safe it will be wrapped in an object that implements MarkupInterface. If it is empty or unsafe it will be a string.

Overrides FieldHandlerInterface::theme

File

core/modules/views/src/Plugin/views/field/FieldPluginBase.php, line 1737

Class

FieldPluginBase
Base class for views fields.

Namespace

Drupal\views\Plugin\views\field

Code

public function theme(ResultRow $values) {
  $renderer = $this
    ->getRenderer();
  $build = [
    '#theme' => $this
      ->themeFunctions(),
    '#view' => $this->view,
    '#field' => $this,
    '#row' => $values,
  ];
  $output = $renderer
    ->render($build);

  // Set the bubbleable rendering metadata on $view->element. This ensures the
  // bubbleable rendering metadata of individual rendered fields is not lost.
  // @see \Drupal\Core\Render\Renderer::updateStack()
  $this->view->element = $renderer
    ->mergeBubbleableMetadata($this->view->element, $build);
  return $output;
}