function FieldPluginBase::theme

Same name and namespace in other branches
  1. 9 core/modules/views/src/Plugin/views/field/FieldPluginBase.php \Drupal\views\Plugin\views\field\FieldPluginBase::theme()
  2. 8.9.x core/modules/views/src/Plugin/views/field/FieldPluginBase.php \Drupal\views\Plugin\views\field\FieldPluginBase::theme()
  3. 11.x core/modules/views/src/Plugin/views/field/FieldPluginBase.php \Drupal\views\Plugin\views\field\FieldPluginBase::theme()

Renders row values using $this->themeFunctions() as #theme.

Parameters

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

Return value

\Drupal\Component\Render\MarkupInterface|string 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 1788

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;
}

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