You are here

public function JSONDataField::render in JSON Field 8

Renders the field.

Parameters

\Drupal\views\ResultRow $values: The values retrieved from a single row of a view's query result.

Return value

string|\Drupal\Component\Render\MarkupInterface The rendered output. 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 FieldPluginBase::render

1 call to JSONDataField::render()
JSONDataField::advancedRender in src/Plugin/views/field/JSONDataField.php
Renders a field using advanced settings.

File

src/Plugin/views/field/JSONDataField.php, line 65

Class

JSONDataField
Field handler to present JSON data to an entity "data" display.

Namespace

Drupal\json_field\Plugin\views\field

Code

public function render(ResultRow $row) {
  $value = $this
    ->getValue($row);
  $build = parent::render($row);

  // Check to make sure the current display handler is of DATA type.
  // @todo Allow other display handlers that support data as well.
  if (!empty($value) && $this->view->display_handler instanceof RestExport) {
    return $this->serializer
      ->decode($value, 'json');
  }
  return $build;
}