public function FieldPluginBase::advancedRender

Render a field using advanced settings.

This renders a field normally, then decides if render-as-link and text-replacement rendering is necessary.

File

drupal/core/modules/views/lib/Drupal/views/Plugin/views/field/FieldPluginBase.php, line 1112
Definition of Drupal\views\Plugin\views\field\FieldPluginBase.

Class

FieldPluginBase
Base field handler that has no options and renders an unformatted field.

Namespace

Drupal\views\Plugin\views\field

Code

public function advancedRender($values) {
  if ($this
    ->allowAdvancedRender() && method_exists($this, 'render_item')) {
    $raw_items = $this
      ->getItems($values);

    // If there are no items, set the original value to NULL.
    if (empty($raw_items)) {
      $this->original_value = NULL;
    }
  }
  else {
    $value = $this
      ->render($values);
    if (is_array($value)) {
      $value = drupal_render($value);
    }
    $this->last_render = $value;
    $this->original_value = $value;
  }
  if ($this
    ->allowAdvancedRender()) {
    $tokens = NULL;
    if (method_exists($this, 'render_item')) {
      $items = array();
      foreach ($raw_items as $count => $item) {
        $value = $this
          ->render_item($count, $item);
        if (is_array($value)) {
          $value = drupal_render($value);
        }
        $this->last_render = $value;
        $this->original_value = $this->last_render;
        $alter = $item + $this->options['alter'];
        $alter['phase'] = VIEWS_HANDLER_RENDER_TEXT_PHASE_SINGLE_ITEM;
        $items[] = $this
          ->renderText($alter);
      }
      $value = $this
        ->renderItems($items);
    }
    else {
      $alter = array(
        'phase' => VIEWS_HANDLER_RENDER_TEXT_PHASE_COMPLETELY,
      ) + $this->options['alter'];
      $value = $this
        ->renderText($alter);
    }
    if (is_array($value)) {
      $value = drupal_render($value);
    }

    // This happens here so that renderAsLink can get the unaltered value of
    // this field as a token rather than the altered value.
    $this->last_render = $value;
  }
  if (empty($this->last_render)) {
    if ($this
      ->isValueEmpty($this->last_render, $this->options['empty_zero'], FALSE)) {
      $alter = $this->options['alter'];
      $alter['alter_text'] = 1;
      $alter['text'] = $this->options['empty'];
      $alter['phase'] = VIEWS_HANDLER_RENDER_TEXT_PHASE_EMPTY;
      $this->last_render = $this
        ->renderText($alter);
    }
  }
  return $this->last_render;
}