You are here

public function DrupalSliderThumbnails::render in Drupal Slider 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/views/field/DrupalSliderThumbnails.php \Drupal\drupal_slider\Plugin\views\field\DrupalSliderThumbnails::render()

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

File

src/Plugin/views/field/DrupalSliderThumbnails.php, line 85

Class

DrupalSliderThumbnails
Field handler for Drupal Slider.

Namespace

Drupal\drupal_slider\Plugin\views\field

Code

public function render(ResultRow $values) {
  if (!empty($values)) {
    $thumbnails = $this->options['thumbnails'];
    $fields = $this->view->display_handler
      ->getHandlers('field');
    $labels = $this->view->display_handler
      ->getFieldLabels();
    foreach ($labels as $key => $var) {

      // If we find a replacement variable, replace it.
      if (strpos($thumbnails, "{{ {$key} }}") !== FALSE) {
        $field = $this
          ->cleanVar($fields[$key]);
        $thumbnails = str_replace("{{ {$key} }}", $field, $thumbnails);
      }
    }
    return $thumbnails;
  }
}