You are here

public function LdapAttribute::render in Lightweight Directory Access Protocol (LDAP) 8.4

Same name and namespace in other branches
  1. 8.3 ldap_query/src/Plugin/views/field/LdapAttribute.php \Drupal\ldap_query\Plugin\views\field\LdapAttribute::render()

Renders the content.

Parameters

\Drupal\views\ResultRow $values: The result row.

Return value

array The processed result in a render array.

Overrides FieldPluginBase::render

1 method overrides LdapAttribute::render()
LdapVariableImageAttribute::render in ldap_query/src/Plugin/views/field/LdapVariableImageAttribute.php
Encodes a binary image for display directly in Views.

File

ldap_query/src/Plugin/views/field/LdapAttribute.php, line 29

Class

LdapAttribute
The handler for loading a specific LDAP field.

Namespace

Drupal\ldap_query\Plugin\views\field

Code

public function render(ResultRow $values) : array {
  $output = '';
  if ($value = $this
    ->getValue($values)) {
    switch ($this->options['multi_value']) {
      case 'v-all':
        $output = implode($this->options['value_separator'], $value);
        break;
      case 'v-count':
        $output = count($value);
        break;
      case 'v-index':
        if ($this->options['index_value'] >= 0) {
          $index = (int) $this->options['index_value'];
        }
        else {

          // Allows for negative offset.
          $index = count($value) + $this->options['index_value'];
        }
        $output = \array_key_exists($index, $value) ? $value[$index] : $value[0];
        break;
    }
  }
  return [
    '#plain_text' => $output,
  ];
}