You are here

class Field in Zircon Profile 8

Same name in this branch
  1. 8 core/modules/views/src/Plugin/views/field/Field.php \Drupal\views\Plugin\views\field\Field
  2. 8 core/modules/field/src/Plugin/migrate/source/d6/Field.php \Drupal\field\Plugin\migrate\source\d6\Field
  3. 8 core/modules/field/src/Plugin/migrate/source/d7/Field.php \Drupal\field\Plugin\migrate\source\d7\Field
Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Plugin/views/field/Field.php \Drupal\views\Plugin\views\field\Field

A field that displays entity field data.

@todo Rename the class https://www.drupal.org/node/2408667

Plugin annotation

@ViewsField("field");

Hierarchy

Expanded class hierarchy of Field

Related topics

6 files declare their use of Field
Depth.php in core/modules/comment/src/Plugin/views/field/Depth.php
Contains \Drupal\comment\Plugin\views\field\Depth.
EntityFieldRenderer.php in core/modules/views/src/Entity/Render/EntityFieldRenderer.php
Contains \Drupal\views\Entity\Render\EntityFieldRenderer.
FieldFieldTest.php in core/modules/views/src/Tests/Handler/FieldFieldTest.php
Contains \Drupal\views\Tests\Handler\FieldFieldTest.
FieldTest.php in core/modules/views/tests/src/Unit/Plugin/field/FieldTest.php
Contains \Drupal\Tests\views\Unit\Plugin\field\FieldTest.
TermName.php in core/modules/taxonomy/src/Plugin/views/field/TermName.php
Contains \Drupal\taxonomy\Plugin\views\field\TermName.

... See full list

12 string references to 'Field'
ConfigTranslationFieldListBuilder::buildHeader in core/modules/config_translation/src/Controller/ConfigTranslationFieldListBuilder.php
Builds the header row for the entity listing.
DataFieldRow::buildOptionsForm in core/modules/rest/src/Plugin/views/row/DataFieldRow.php
Provide a form for setting options.
ElementNotFoundExceptionTest::provideExceptionMessage in vendor/behat/mink/tests/Exception/ElementNotFoundExceptionTest.php
EntityFormDisplayEditForm::getTableHeader in core/modules/field_ui/src/Form/EntityFormDisplayEditForm.php
Returns an array containing the table headers.
EntityViewDisplayEditForm::getTableHeader in core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php
Returns an array containing the table headers.

... See full list

File

core/modules/views/src/Plugin/views/field/Field.php, line 41
Contains \Drupal\views\Plugin\views\field\Field.

Namespace

Drupal\views\Plugin\views\field
View source
class Field extends FieldPluginBase implements CacheableDependencyInterface, MultiItemsFieldHandlerInterface {
  use FieldAPIHandlerTrait;

  /**
   * An array to store field renderable arrays for use by renderItems().
   *
   * @var array
   */
  public $items = array();

  /**
   * Does the field supports multiple field values.
   *
   * @var bool
   */
  public $multiple;

  /**
   * Does the rendered fields get limited.
   *
   * @var bool
   */
  public $limit_values;

  /**
   * A shortcut for $view->base_table.
   *
   * @var string
   */
  public $base_table;

  /**
   * An array of formatter options.
   *
   * @var array
   */
  protected $formatterOptions;

  /**
   * The entity manager.
   *
   * @var \Drupal\Core\Entity\EntityManagerInterface
   */
  protected $entityManager;

  /**
   * The field formatter plugin manager.
   *
   * @var \Drupal\Core\Field\FormatterPluginManager
   */
  protected $formatterPluginManager;

  /**
   * The language manager.
   *
   * @var \Drupal\Core\Language\LanguageManagerInterface
   */
  protected $languageManager;

  /**
   * The renderer.
   *
   * @var \Drupal\Core\Render\RendererInterface
   */
  protected $renderer;

  /**
   * The field type plugin manager.
   *
   * @var \Drupal\Core\Field\FieldTypePluginManagerInterface
   */
  protected $fieldTypePluginManager;

  /**
   * Static cache for ::getEntityFieldRenderer().
   *
   * @var \Drupal\views\Entity\Render\EntityFieldRenderer
   */
  protected $entityFieldRenderer;

  /**
   * Constructs a \Drupal\field\Plugin\views\field\Field object.
   *
   * @param array $configuration
   *   A configuration array containing information about the plugin instance.
   * @param string $plugin_id
   *   The plugin_id for the plugin instance.
   * @param mixed $plugin_definition
   *   The plugin implementation definition.
   * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
   *   The field formatter plugin manager.
   * @param \Drupal\Core\Field\FormatterPluginManager $formatter_plugin_manager
   *   The field formatter plugin manager.
   * @param \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_plugin_manager
   *   The field plugin type manager.
   * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
   *   The language manager.
   * @param \Drupal\Core\Render\RendererInterface $renderer
   *   The renderer.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager, FormatterPluginManager $formatter_plugin_manager, FieldTypePluginManagerInterface $field_type_plugin_manager, LanguageManagerInterface $language_manager, RendererInterface $renderer) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->entityManager = $entity_manager;
    $this->formatterPluginManager = $formatter_plugin_manager;
    $this->fieldTypePluginManager = $field_type_plugin_manager;
    $this->languageManager = $language_manager;
    $this->renderer = $renderer;

    // @todo Unify 'entity field'/'field_name' instead of converting back and
    //   forth. https://www.drupal.org/node/2410779
    if (isset($this->definition['entity field'])) {
      $this->definition['field_name'] = $this->definition['entity field'];
    }
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static($configuration, $plugin_id, $plugin_definition, $container
      ->get('entity.manager'), $container
      ->get('plugin.manager.field.formatter'), $container
      ->get('plugin.manager.field.field_type'), $container
      ->get('language_manager'), $container
      ->get('renderer'));
  }

  /**
   * {@inheritdoc}
   */
  public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
    parent::init($view, $display, $options);
    $this->multiple = FALSE;
    $this->limit_values = FALSE;
    $field_definition = $this
      ->getFieldDefinition();
    $cardinality = $field_definition
      ->getFieldStorageDefinition()
      ->getCardinality();
    if ($field_definition
      ->getFieldStorageDefinition()
      ->isMultiple()) {
      $this->multiple = TRUE;

      // If "Display all values in the same row" is FALSE, then we always limit
      // in order to show a single unique value per row.
      if (!$this->options['group_rows']) {
        $this->limit_values = TRUE;
      }

      // If "First and last only" is chosen, limit the values
      if (!empty($this->options['delta_first_last'])) {
        $this->limit_values = TRUE;
      }

      // Otherwise, we only limit values if the user hasn't selected "all", 0, or
      // the value matching field cardinality.
      if ($this->options['delta_limit'] > 0 && $this->options['delta_limit'] != $cardinality || intval($this->options['delta_offset'])) {
        $this->limit_values = TRUE;
      }
    }
  }

  /**
   * {@inheritdoc}
   */
  protected function getEntityManager() {
    return $this->entityManager;
  }

  /**
   * {@inheritdoc}
   */
  public function access(AccountInterface $account) {
    $access_control_handler = $this->entityManager
      ->getAccessControlHandler($this
      ->getEntityType());
    return $access_control_handler
      ->fieldAccess('view', $this
      ->getFieldDefinition(), $account);
  }

  /**
   * Called to add the field to a query.
   *
   * By default, all needed data is taken from entities loaded by the query
   * plugin. Columns are added only if they are used in groupings.
   */
  public function query($use_groupby = FALSE) {
    $fields = $this->additional_fields;

    // No need to add the entity type.
    $entity_type_key = array_search('entity_type', $fields);
    if ($entity_type_key !== FALSE) {
      unset($fields[$entity_type_key]);
    }
    if ($use_groupby) {

      // Add the fields that we're actually grouping on.
      $options = array();
      if ($this->options['group_column'] != 'entity_id') {
        $options = array(
          $this->options['group_column'] => $this->options['group_column'],
        );
      }
      $options += is_array($this->options['group_columns']) ? $this->options['group_columns'] : array();

      // Go through the list and determine the actual column name from field api.
      $fields = array();
      foreach ($options as $column) {
        $fields[$column] = $this
          ->getTableMapping()
          ->getFieldColumnName($this
          ->getFieldStorageDefinition(), $column);
      }
      $this->group_fields = $fields;
    }

    // Add additional fields (and the table join itself) if needed.
    if ($this
      ->add_field_table($use_groupby)) {
      $this
        ->ensureMyTable();
      $this
        ->addAdditionalFields($fields);
    }

    // Let the entity field renderer alter the query if needed.
    $this
      ->getEntityFieldRenderer()
      ->query($this->query, $this->relationship);
  }

  /**
   * Determine if the field table should be added to the query.
   */
  function add_field_table($use_groupby) {

    // Grouping is enabled.
    if ($use_groupby) {
      return TRUE;
    }

    // This a multiple value field, but "group multiple values" is not checked.
    if ($this->multiple && !$this->options['group_rows']) {
      return TRUE;
    }
    return FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function clickSortable() {

    // A field is not click sortable if it's a multiple field with
    // "group multiple values" checked, since a click sort in that case would
    // add a join to the field table, which would produce unwanted duplicates.
    if ($this->multiple && $this->options['group_rows']) {
      return FALSE;
    }

    // If field definition is set, use that.
    if (isset($this->definition['click sortable'])) {
      return (bool) $this->definition['click sortable'];
    }

    // Default to true.
    return TRUE;
  }

  /**
   * Called to determine what to tell the clicksorter.
   */
  public function clickSort($order) {

    // No column selected, can't continue.
    if (empty($this->options['click_sort_column'])) {
      return;
    }
    $this
      ->ensureMyTable();
    $field_storage_definition = $this
      ->getFieldStorageDefinition();
    $column = $this
      ->getTableMapping()
      ->getFieldColumnName($field_storage_definition, $this->options['click_sort_column']);
    if (!isset($this->aliases[$column])) {

      // Column is not in query; add a sort on it (without adding the column).
      $this->aliases[$column] = $this->tableAlias . '.' . $column;
    }
    $this->query
      ->addOrderBy(NULL, NULL, $order, $this->aliases[$column]);
  }

  /**
   * Gets the field storage of the used field.
   *
   * @return \Drupal\Core\Field\FieldStorageDefinitionInterface
   */
  protected function getFieldStorageDefinition() {
    $entity_type_id = $this->definition['entity_type'];
    $field_storage_definitions = $this->entityManager
      ->getFieldStorageDefinitions($entity_type_id);
    $field_storage = NULL;

    // @todo Unify 'entity field'/'field_name' instead of converting back and
    //   forth. https://www.drupal.org/node/2410779
    if (isset($this->definition['field_name'])) {
      $field_storage = $field_storage_definitions[$this->definition['field_name']];
    }
    elseif (isset($this->definition['entity field'])) {
      $field_storage = $field_storage_definitions[$this->definition['entity field']];
    }
    return $field_storage;
  }

  /**
   * {@inheritdoc}
   */
  protected function defineOptions() {
    $options = parent::defineOptions();
    $field_storage_definition = $this
      ->getFieldStorageDefinition();
    $field_type = $this->fieldTypePluginManager
      ->getDefinition($field_storage_definition
      ->getType());
    $column_names = array_keys($field_storage_definition
      ->getColumns());
    $default_column = '';

    // Try to determine a sensible default.
    if (count($column_names) == 1) {
      $default_column = $column_names[0];
    }
    elseif (in_array('value', $column_names)) {
      $default_column = 'value';
    }

    // If the field has a "value" column, we probably need that one.
    $options['click_sort_column'] = array(
      'default' => $default_column,
    );
    if (isset($this->definition['default_formatter'])) {
      $options['type'] = [
        'default' => $this->definition['default_formatter'],
      ];
    }
    elseif (isset($field_type['default_formatter'])) {
      $options['type'] = [
        'default' => $field_type['default_formatter'],
      ];
    }
    else {
      $options['type'] = [
        'default' => '',
      ];
    }
    $options['settings'] = array(
      'default' => isset($this->definition['default_formatter_settings']) ? $this->definition['default_formatter_settings'] : [],
    );
    $options['group_column'] = array(
      'default' => $default_column,
    );
    $options['group_columns'] = array(
      'default' => array(),
    );

    // Options used for multiple value fields.
    $options['group_rows'] = array(
      'default' => TRUE,
    );

    // If we know the exact number of allowed values, then that can be
    // the default. Otherwise, default to 'all'.
    $options['delta_limit'] = array(
      'default' => $field_storage_definition
        ->getCardinality() > 1 ? $field_storage_definition
        ->getCardinality() : 0,
    );
    $options['delta_offset'] = array(
      'default' => 0,
    );
    $options['delta_reversed'] = array(
      'default' => FALSE,
    );
    $options['delta_first_last'] = array(
      'default' => FALSE,
    );
    $options['multi_type'] = array(
      'default' => 'separator',
    );
    $options['separator'] = array(
      'default' => ', ',
    );
    $options['field_api_classes'] = array(
      'default' => FALSE,
    );
    return $options;
  }

  /**
   * {@inheritdoc}
   */
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form, $form_state);
    $field = $this
      ->getFieldDefinition();
    $formatters = $this->formatterPluginManager
      ->getOptions($field
      ->getType());
    $column_names = array_keys($field
      ->getColumns());

    // If this is a multiple value field, add its options.
    if ($this->multiple) {
      $this
        ->multiple_options_form($form, $form_state);
    }

    // No need to ask the user anything if the field has only one column.
    if (count($field
      ->getColumns()) == 1) {
      $form['click_sort_column'] = array(
        '#type' => 'value',
        '#value' => isset($column_names[0]) ? $column_names[0] : '',
      );
    }
    else {
      $form['click_sort_column'] = array(
        '#type' => 'select',
        '#title' => $this
          ->t('Column used for click sorting'),
        '#options' => array_combine($column_names, $column_names),
        '#default_value' => $this->options['click_sort_column'],
        '#description' => $this
          ->t('Used by Style: Table to determine the actual column to click sort the field on. The default is usually fine.'),
      );
    }
    $form['type'] = array(
      '#type' => 'select',
      '#title' => $this
        ->t('Formatter'),
      '#options' => $formatters,
      '#default_value' => $this->options['type'],
      '#ajax' => array(
        'url' => views_ui_build_form_url($form_state),
      ),
      '#submit' => array(
        array(
          $this,
          'submitTemporaryForm',
        ),
      ),
      '#executes_submit_callback' => TRUE,
    );
    $form['field_api_classes'] = array(
      '#title' => $this
        ->t('Use field template'),
      '#type' => 'checkbox',
      '#default_value' => $this->options['field_api_classes'],
      '#description' => $this
        ->t('If checked, field api classes will be added by field templates. This is not recommended unless your CSS depends upon these classes. If not checked, template will not be used.'),
      '#fieldset' => 'style_settings',
      '#weight' => 20,
    );
    if ($this->multiple) {
      $form['field_api_classes']['#description'] .= ' ' . $this
        ->t('Checking this option will cause the group Display Type and Separator values to be ignored.');
    }

    // Get the currently selected formatter.
    $format = $this->options['type'];
    $settings = $this->options['settings'] + $this->formatterPluginManager
      ->getDefaultSettings($format);
    $options = array(
      'field_definition' => $field,
      'configuration' => array(
        'type' => $format,
        'settings' => $settings,
        'label' => '',
        'weight' => 0,
      ),
      'view_mode' => '_custom',
    );

    // Get the settings form.
    $settings_form = array(
      '#value' => array(),
    );
    if ($formatter = $this->formatterPluginManager
      ->getInstance($options)) {
      $settings_form = $formatter
        ->settingsForm($form, $form_state);

      // Convert field UI selector states to work in the Views field form.
      FormHelper::rewriteStatesSelector($settings_form, "fields[{$field->getName()}][settings_edit_form]", 'options');
    }
    $form['settings'] = $settings_form;
  }

  /**
   * Provide options for multiple value fields.
   */
  function multiple_options_form(&$form, FormStateInterface $form_state) {
    $field = $this
      ->getFieldDefinition();
    $form['multiple_field_settings'] = array(
      '#type' => 'details',
      '#title' => $this
        ->t('Multiple field settings'),
      '#weight' => 5,
    );
    $form['group_rows'] = array(
      '#title' => $this
        ->t('Display all values in the same row'),
      '#type' => 'checkbox',
      '#default_value' => $this->options['group_rows'],
      '#description' => $this
        ->t('If checked, multiple values for this field will be shown in the same row. If not checked, each value in this field will create a new row. If using group by, please make sure to group by "Entity ID" for this setting to have any effect.'),
      '#fieldset' => 'multiple_field_settings',
    );

    // Make the string translatable by keeping it as a whole rather than
    // translating prefix and suffix separately.
    list($prefix, $suffix) = explode('@count', $this
      ->t('Display @count value(s)'));
    if ($field
      ->getCardinality() == FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) {
      $type = 'textfield';
      $options = NULL;
      $size = 5;
    }
    else {
      $type = 'select';
      $range = range(1, $field
        ->getCardinality());
      $options = array_combine($range, $range);
      $size = 1;
    }
    $form['multi_type'] = array(
      '#type' => 'radios',
      '#title' => $this
        ->t('Display type'),
      '#options' => array(
        'ul' => $this
          ->t('Unordered list'),
        'ol' => $this
          ->t('Ordered list'),
        'separator' => $this
          ->t('Simple separator'),
      ),
      '#states' => array(
        'visible' => array(
          ':input[name="options[group_rows]"]' => array(
            'checked' => TRUE,
          ),
        ),
      ),
      '#default_value' => $this->options['multi_type'],
      '#fieldset' => 'multiple_field_settings',
    );
    $form['separator'] = array(
      '#type' => 'textfield',
      '#title' => $this
        ->t('Separator'),
      '#default_value' => $this->options['separator'],
      '#states' => array(
        'visible' => array(
          ':input[name="options[group_rows]"]' => array(
            'checked' => TRUE,
          ),
          ':input[name="options[multi_type]"]' => array(
            'value' => 'separator',
          ),
        ),
      ),
      '#fieldset' => 'multiple_field_settings',
    );
    $form['delta_limit'] = array(
      '#type' => $type,
      '#size' => $size,
      '#field_prefix' => $prefix,
      '#field_suffix' => $suffix,
      '#options' => $options,
      '#default_value' => $this->options['delta_limit'],
      '#prefix' => '<div class="container-inline">',
      '#states' => array(
        'visible' => array(
          ':input[name="options[group_rows]"]' => array(
            'checked' => TRUE,
          ),
        ),
      ),
      '#fieldset' => 'multiple_field_settings',
    );
    list($prefix, $suffix) = explode('@count', $this
      ->t('starting from @count'));
    $form['delta_offset'] = array(
      '#type' => 'textfield',
      '#size' => 5,
      '#field_prefix' => $prefix,
      '#field_suffix' => $suffix,
      '#default_value' => $this->options['delta_offset'],
      '#states' => array(
        'visible' => array(
          ':input[name="options[group_rows]"]' => array(
            'checked' => TRUE,
          ),
        ),
      ),
      '#description' => $this
        ->t('(first item is 0)'),
      '#fieldset' => 'multiple_field_settings',
    );
    $form['delta_reversed'] = array(
      '#title' => $this
        ->t('Reversed'),
      '#type' => 'checkbox',
      '#default_value' => $this->options['delta_reversed'],
      '#suffix' => $suffix,
      '#states' => array(
        'visible' => array(
          ':input[name="options[group_rows]"]' => array(
            'checked' => TRUE,
          ),
        ),
      ),
      '#description' => $this
        ->t('(start from last values)'),
      '#fieldset' => 'multiple_field_settings',
    );
    $form['delta_first_last'] = array(
      '#title' => $this
        ->t('First and last only'),
      '#type' => 'checkbox',
      '#default_value' => $this->options['delta_first_last'],
      '#suffix' => '</div>',
      '#states' => array(
        'visible' => array(
          ':input[name="options[group_rows]"]' => array(
            'checked' => TRUE,
          ),
        ),
      ),
      '#fieldset' => 'multiple_field_settings',
    );
  }

  /**
   * Extend the groupby form with group columns.
   */
  public function buildGroupByForm(&$form, FormStateInterface $form_state) {
    parent::buildGroupByForm($form, $form_state);

    // With "field API" fields, the column target of the grouping function
    // and any additional grouping columns must be specified.
    $field_columns = array_keys($this
      ->getFieldDefinition()
      ->getColumns());
    $group_columns = array(
      'entity_id' => $this
        ->t('Entity ID'),
    ) + array_map('ucfirst', array_combine($field_columns, $field_columns));
    $form['group_column'] = array(
      '#type' => 'select',
      '#title' => $this
        ->t('Group column'),
      '#default_value' => $this->options['group_column'],
      '#description' => $this
        ->t('Select the column of this field to apply the grouping function selected above.'),
      '#options' => $group_columns,
    );
    $options = array(
      'bundle' => 'Bundle',
      'language' => 'Language',
      'entity_type' => 'Entity_type',
    );

    // Add on defined fields, noting that they're prefixed with the field name.
    $form['group_columns'] = array(
      '#type' => 'checkboxes',
      '#title' => $this
        ->t('Group columns (additional)'),
      '#default_value' => $this->options['group_columns'],
      '#description' => $this
        ->t('Select any additional columns of this field to include in the query and to group on.'),
      '#options' => $options + $group_columns,
    );
  }
  public function submitGroupByForm(&$form, FormStateInterface $form_state) {
    parent::submitGroupByForm($form, $form_state);
    $item =& $form_state
      ->get('handler')->options;

    // Add settings for "field API" fields.
    $item['group_column'] = $form_state
      ->getValue(array(
      'options',
      'group_column',
    ));
    $item['group_columns'] = array_filter($form_state
      ->getValue(array(
      'options',
      'group_columns',
    )));
  }

  /**
   * Render all items in this field together.
   *
   * When using advanced render, each possible item in the list is rendered
   * individually. Then the items are all pasted together.
   */
  public function renderItems($items) {
    if (!empty($items)) {
      $items = $this
        ->prepareItemsByDelta($items);
      if ($this->options['multi_type'] == 'separator' || !$this->options['group_rows']) {
        $separator = $this->options['multi_type'] == 'separator' ? Xss::filterAdmin($this->options['separator']) : '';
        $build = [
          '#type' => 'inline_template',
          '#template' => '{{ items | safe_join(separator) }}',
          '#context' => [
            'separator' => $separator,
            'items' => $items,
          ],
        ];
      }
      else {
        $build = array(
          '#theme' => 'item_list',
          '#items' => $items,
          '#title' => NULL,
          '#list_type' => $this->options['multi_type'],
        );
      }
      return $this->renderer
        ->render($build);
    }
  }

  /**
   * Adapts the $items according to the delta configuration.
   *
   * This selects displayed deltas, reorders items, and takes offsets into
   * account.
   *
   * @param array $all_values
   *   The items for individual rendering.
   *
   * @return array
   *   The manipulated items.
   */
  protected function prepareItemsByDelta(array $all_values) {
    if ($this->options['delta_reversed']) {
      $all_values = array_reverse($all_values);
    }

    // We are supposed to show only certain deltas.
    if ($this->limit_values) {
      $row = $this->view->result[$this->view->row_index];

      // Offset is calculated differently when row grouping for a field is not
      // enabled. Since there are multiple rows, delta needs to be taken into
      // account, so that different values are shown per row.
      if (!$this->options['group_rows'] && isset($this->aliases['delta']) && isset($row->{$this->aliases['delta']})) {
        $delta_limit = 1;
        $offset = $row->{$this->aliases['delta']};
      }
      elseif (!$this->options['group_rows'] && !$this->multiple) {
        $delta_limit = 1;
        $offset = 0;
      }
      else {
        $delta_limit = $this->options['delta_limit'];
        $offset = intval($this->options['delta_offset']);

        // We should only get here in this case if there is an offset, and in
        // that case we are limiting to all values after the offset.
        if ($delta_limit === 0) {
          $delta_limit = count($all_values) - $offset;
        }
      }

      // Determine if only the first and last values should be shown.
      $delta_first_last = $this->options['delta_first_last'];
      $new_values = array();
      for ($i = 0; $i < $delta_limit; $i++) {
        $new_delta = $offset + $i;
        if (isset($all_values[$new_delta])) {

          // If first-last option was selected, only use the first and last
          // values.
          if (!$delta_first_last || $new_delta == $offset || $new_delta == $delta_limit + $offset - 1) {
            $new_values[] = $all_values[$new_delta];
          }
        }
      }
      $all_values = $new_values;
    }
    return $all_values;
  }

  /**
   * {@inheritdoc}
   */
  public function preRender(&$values) {
    parent::preRender($values);
    $this
      ->getEntityFieldRenderer()
      ->preRender($values);
  }

  /**
   * Returns the entity field renderer.
   *
   * @return \Drupal\views\Entity\Render\EntityFieldRenderer
   *   The entity field renderer.
   */
  protected function getEntityFieldRenderer() {
    if (!isset($this->entityFieldRenderer)) {

      // This can be invoked during field handler initialization in which case
      // view fields are not set yet.
      if (!empty($this->view->field)) {
        foreach ($this->view->field as $field) {

          // An entity field renderer can handle only a single relationship.
          if ($field->relationship == $this->relationship && isset($field->entityFieldRenderer)) {
            $this->entityFieldRenderer = $field->entityFieldRenderer;
            break;
          }
        }
      }
      if (!isset($this->entityFieldRenderer)) {
        $entity_type = $this->entityManager
          ->getDefinition($this
          ->getEntityType());
        $this->entityFieldRenderer = new EntityFieldRenderer($this->view, $this->relationship, $this->languageManager, $entity_type, $this->entityManager);
      }
    }
    return $this->entityFieldRenderer;
  }

  /**
   * Gets an array of items for the field.
   *
   * @param \Drupal\views\ResultRow $values
   *   The result row object containing the values.
   *
   * @return array
   *   An array of items for the field.
   */
  public function getItems(ResultRow $values) {
    if (!$this->displayHandler
      ->useGroupBy()) {
      $build_list = $this
        ->getEntityFieldRenderer()
        ->render($values, $this);
    }
    else {

      // For grouped results we need to retrieve a massaged entity having
      // grouped field values to ensure that "grouped by" values, especially
      // those with multiple cardinality work properly. See
      // \Drupal\views\Tests\QueryGroupByTest::testGroupByFieldWithCardinality.
      $display = [
        'type' => $this->options['type'],
        'settings' => $this->options['settings'],
        'label' => 'hidden',
      ];
      $build_list = $this
        ->createEntityForGroupBy($this
        ->getEntity($values), $values)->{$this->definition['field_name']}
        ->view($display);
    }
    if (!$build_list) {
      return [];
    }
    if ($this->options['field_api_classes']) {
      return [
        [
          'rendered' => $this->renderer
            ->render($build_list),
        ],
      ];
    }

    // Render using the formatted data itself.
    $items = [];

    // Each item is extracted and rendered separately, the top-level formatter
    // render array itself is never rendered, so we extract its bubbleable
    // metadata and add it to each child individually.
    $bubbleable = BubbleableMetadata::createFromRenderArray($build_list);
    foreach (Element::children($build_list) as $delta) {
      BubbleableMetadata::createFromRenderArray($build_list[$delta])
        ->merge($bubbleable)
        ->applyTo($build_list[$delta]);
      $items[$delta] = [
        'rendered' => $build_list[$delta],
        // Add the raw field items (for use in tokens).
        'raw' => $build_list['#items'][$delta],
      ];
    }
    return $items;
  }

  /**
   * Creates a fake entity with grouped field values.
   *
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *   The entity to be processed.
   * @param \Drupal\views\ResultRow $row
   *   The result row object containing the values.
   *
   * @return bool|\Drupal\Core\Entity\FieldableEntityInterface
   *   Returns a new entity object containing the grouped field values.
   */
  protected function createEntityForGroupBy(EntityInterface $entity, ResultRow $row) {

    // Retrieve the correct translation object.
    $processed_entity = clone $this
      ->getEntityFieldRenderer()
      ->getEntityTranslation($entity, $row);

    // Copy our group fields into the cloned entity. It is possible this will
    // cause some weirdness, but there is only so much we can hope to do.
    if (!empty($this->group_fields) && isset($entity->{$this->definition['field_name']})) {

      // first, test to see if we have a base value.
      $base_value = array();

      // Note: We would copy original values here, but it can cause problems.
      // For example, text fields store cached filtered values as 'safe_value'
      // which does not appear anywhere in the field definition so we cannot
      // affect it. Other side effects could happen similarly.
      $data = FALSE;
      foreach ($this->group_fields as $field_name => $column) {
        if (property_exists($row, $this->aliases[$column])) {
          $base_value[$field_name] = $row->{$this->aliases[$column]};
          if (isset($base_value[$field_name])) {
            $data = TRUE;
          }
        }
      }

      // If any of our aggregated fields have data, fake it:
      if ($data) {

        // Now, overwrite the original value with our aggregated value.
        // This overwrites it so there is always just one entry.
        $processed_entity->{$this->definition['field_name']} = array(
          $base_value,
        );
      }
      else {
        $processed_entity->{$this->definition['field_name']} = array();
      }
    }
    return $processed_entity;
  }
  function render_item($count, $item) {
    return render($item['rendered']);
  }
  protected function documentSelfTokens(&$tokens) {
    $field = $this
      ->getFieldDefinition();
    foreach ($field
      ->getColumns() as $id => $column) {
      $tokens['{{ ' . $this->options['id'] . '__' . $id . ' }}'] = $this
        ->t('Raw @column', array(
        '@column' => $id,
      ));
    }
  }
  protected function addSelfTokens(&$tokens, $item) {
    $field = $this
      ->getFieldDefinition();
    foreach ($field
      ->getColumns() as $id => $column) {

      // Use \Drupal\Component\Utility\Xss::filterAdmin() because it's user data
      // and we can't be sure it is safe. We know nothing about the data,
      // though, so we can't really do much else.
      if (isset($item['raw'])) {
        $raw = $item['raw'];
        if (is_array($raw)) {
          if (isset($raw[$id]) && is_scalar($raw[$id])) {
            $tokens['{{ ' . $this->options['id'] . '__' . $id . ' }}'] = Xss::filterAdmin($raw[$id]);
          }
          else {

            // Make sure that empty values are replaced as well.
            $tokens['{{ ' . $this->options['id'] . '__' . $id . ' }}'] = '';
          }
        }
        if (is_object($raw)) {
          $property = $raw
            ->get($id);
          if (!empty($property)) {
            $tokens['{{ ' . $this->options['id'] . '__' . $id . ' }}'] = Xss::filterAdmin($property
              ->getValue());
          }
          else {

            // Make sure that empty values are replaced as well.
            $tokens['{{ ' . $this->options['id'] . '__' . $id . ' }}'] = '';
          }
        }
      }
    }
  }

  /**
   * {@inheritdoc}
   */
  public function calculateDependencies() {
    $dependencies = parent::calculateDependencies();

    // Add the module providing the configured field storage as a dependency.
    if (($field_storage_definition = $this
      ->getFieldStorageDefinition()) && $field_storage_definition instanceof EntityInterface) {
      $dependencies['config'][] = $field_storage_definition
        ->getConfigDependencyName();
    }

    // Add the module providing the formatter.
    if (!empty($this->options['type'])) {
      $dependencies['module'][] = $this->formatterPluginManager
        ->getDefinition($this->options['type'])['provider'];
    }
    return $dependencies;
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheMaxAge() {
    return Cache::PERMANENT;
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheContexts() {
    return $this
      ->getEntityFieldRenderer()
      ->getCacheContexts();
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheTags() {
    $field_definition = $this
      ->getFieldDefinition();
    $field_storage_definition = $this
      ->getFieldStorageDefinition();
    return Cache::mergeTags($field_definition instanceof CacheableDependencyInterface ? $field_definition
      ->getCacheTags() : [], $field_storage_definition instanceof CacheableDependencyInterface ? $field_storage_definition
      ->getCacheTags() : []);
  }

  /**
   * Gets the table mapping for the entity type of the field.
   *
   * @return \Drupal\Core\Entity\Sql\DefaultTableMapping
   *   The table mapping.
   */
  protected function getTableMapping() {
    return $this->entityManager
      ->getStorage($this->definition['entity_type'])
      ->getTableMapping();
  }

  /**
   * {@inheritdoc}
   */
  public function getValue(ResultRow $values, $field = NULL) {

    /** @var \Drupal\Core\Field\FieldItemListInterface $field_item_list */
    $field_item_list = $this
      ->getEntity($values)->{$this->definition['field_name']};
    $field_item_definition = $field_item_list
      ->getFieldDefinition();
    if ($field_item_definition
      ->getFieldStorageDefinition()
      ->getCardinality() == 1) {
      return $field ? $field_item_list->{$field} : $field_item_list->value;
    }
    $values = [];
    foreach ($field_item_list as $field_item) {
      $values[] = $field ? $field_item->{$field} : $field_item->value;
    }
    return $values;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
Field::$base_table public property A shortcut for $view->base_table.
Field::$entityFieldRenderer protected property Static cache for ::getEntityFieldRenderer().
Field::$entityManager protected property The entity manager.
Field::$fieldTypePluginManager protected property The field type plugin manager.
Field::$formatterOptions protected property An array of formatter options.
Field::$formatterPluginManager protected property The field formatter plugin manager.
Field::$items public property An array to store field renderable arrays for use by renderItems().
Field::$languageManager protected property The language manager.
Field::$limit_values public property Does the rendered fields get limited.
Field::$multiple public property Does the field supports multiple field values.
Field::$renderer protected property The renderer. Overrides FieldPluginBase::$renderer
Field::access public function Check whether given user has access to this handler. Overrides HandlerBase::access
Field::addSelfTokens protected function Add any special tokens this field might use for itself. Overrides FieldPluginBase::addSelfTokens
Field::add_field_table function Determine if the field table should be added to the query.
Field::buildGroupByForm public function Extend the groupby form with group columns. Overrides HandlerBase::buildGroupByForm
Field::buildOptionsForm public function Default options form that provides the label widget that all fields should have. Overrides FieldPluginBase::buildOptionsForm 1
Field::calculateDependencies public function Calculates dependencies for the configured plugin. Overrides PluginBase::calculateDependencies
Field::clickSort public function Called to determine what to tell the clicksorter. Overrides FieldPluginBase::clickSort
Field::clickSortable public function Determines if this field is click sortable. Overrides FieldPluginBase::clickSortable
Field::create public static function Creates an instance of the plugin. Overrides PluginBase::create
Field::createEntityForGroupBy protected function Creates a fake entity with grouped field values.
Field::defineOptions protected function Information about options for all kinds of purposes will be held here. Overrides FieldPluginBase::defineOptions 1
Field::documentSelfTokens protected function Document any special tokens this field might use for itself. Overrides FieldPluginBase::documentSelfTokens
Field::getCacheContexts public function The cache contexts associated with this object. Overrides CacheableDependencyInterface::getCacheContexts
Field::getCacheMaxAge public function The maximum age for which this object may be cached. Overrides CacheableDependencyInterface::getCacheMaxAge
Field::getCacheTags public function The cache tags associated with this object. Overrides CacheableDependencyInterface::getCacheTags
Field::getEntityFieldRenderer protected function Returns the entity field renderer.
Field::getEntityManager protected function Returns the entity manager. Overrides FieldAPIHandlerTrait::getEntityManager
Field::getFieldStorageDefinition protected function Gets the field storage of the used field. Overrides FieldAPIHandlerTrait::getFieldStorageDefinition
Field::getItems public function Gets an array of items for the field. Overrides MultiItemsFieldHandlerInterface::getItems 2
Field::getTableMapping protected function Gets the table mapping for the entity type of the field.
Field::getValue public function Gets the value that's supposed to be rendered. Overrides FieldPluginBase::getValue
Field::init public function Initialize the plugin. Overrides FieldPluginBase::init
Field::multiple_options_form function Provide options for multiple value fields.
Field::prepareItemsByDelta protected function Adapts the $items according to the delta configuration.
Field::preRender public function Runs before any fields are rendered. Overrides FieldPluginBase::preRender
Field::query public function Called to add the field to a query. Overrides FieldPluginBase::query
Field::renderItems public function Render all items in this field together. Overrides MultiItemsFieldHandlerInterface::renderItems
Field::render_item function Renders a single item of a row. Overrides MultiItemsFieldHandlerInterface::render_item
Field::submitGroupByForm public function Perform any necessary changes to the form values prior to storage. There is no need for this function to actually store the data. Overrides HandlerBase::submitGroupByForm
Field::__construct public function Constructs a \Drupal\field\Plugin\views\field\Field object. Overrides HandlerBase::__construct
FieldAPIHandlerTrait::$fieldDefinition protected property The field definition.
FieldAPIHandlerTrait::$fieldStorageDefinition protected property The field storage definition.
FieldAPIHandlerTrait::getFieldDefinition protected function Gets the field definition.
FieldPluginBase::$additional_fields property Stores additional fields which get's added to the query. The generated aliases are stored in $aliases.
FieldPluginBase::$aliases property
FieldPluginBase::$field_alias property
FieldPluginBase::$linkGenerator protected property The link generator.
FieldPluginBase::$original_value public property The field value prior to any rewriting.
FieldPluginBase::addAdditionalFields protected function Add 'additional' fields to the query.
FieldPluginBase::adminLabel public function Return a string representing this handler's name in the UI. Overrides HandlerBase::adminLabel
FieldPluginBase::adminSummary public function Provide extra data to the administration form Overrides HandlerBase::adminSummary
FieldPluginBase::advancedRender public function Renders a field using advanced settings. Overrides FieldHandlerInterface::advancedRender
FieldPluginBase::allowAdvancedRender protected function Determine if this field can allow advanced rendering.
FieldPluginBase::elementClasses public function Returns the class of the field. Overrides FieldHandlerInterface::elementClasses
FieldPluginBase::elementLabelClasses public function Returns the class of the field's label. Overrides FieldHandlerInterface::elementLabelClasses
FieldPluginBase::elementLabelType public function Returns an HTML element for the label based upon the field's element type. Overrides FieldHandlerInterface::elementLabelType
FieldPluginBase::elementType public function Returns an HTML element based upon the field's element type. Overrides FieldHandlerInterface::elementType 1
FieldPluginBase::elementWrapperClasses public function Returns the class of the field's wrapper. Overrides FieldHandlerInterface::elementWrapperClasses
FieldPluginBase::elementWrapperType public function Returns an HTML element for the wrapper based upon the field's element type. Overrides FieldHandlerInterface::elementWrapperType
FieldPluginBase::getElements public function Provides a list of elements valid for field HTML. Overrides FieldHandlerInterface::getElements
FieldPluginBase::getEntity public function Gets the entity matching the current row and relationship. Overrides FieldHandlerInterface::getEntity
FieldPluginBase::getFieldTokenPlaceholder protected function Returns a token placeholder for the current field.
FieldPluginBase::getPreviousFieldLabels protected function Returns all field labels of fields before this field.
FieldPluginBase::getRenderer protected function Returns the render API renderer. Overrides PluginBase::getRenderer
FieldPluginBase::getRenderTokens public function Gets the 'render' tokens to use for advanced rendering. Overrides FieldHandlerInterface::getRenderTokens
FieldPluginBase::getTokenValuesRecursive protected function Recursive function to add replacements for nested query string parameters.
FieldPluginBase::isValueEmpty public function Checks if a field value is empty. Overrides FieldHandlerInterface::isValueEmpty
FieldPluginBase::label public function Gets this field's label. Overrides FieldHandlerInterface::label
FieldPluginBase::linkGenerator protected function Gets the link generator.
FieldPluginBase::postRender public function Runs after every field has been rendered. Overrides FieldHandlerInterface::postRender
FieldPluginBase::render public function Renders the field. Overrides FieldHandlerInterface::render 25
FieldPluginBase::renderAltered protected function Render this field as user-defined altered text.
FieldPluginBase::renderAsLink protected function Render this field as a link, with the info from a fieldset set by the user.
FieldPluginBase::renderText public function Performs an advanced text render for the item. Overrides FieldHandlerInterface::renderText
FieldPluginBase::renderTrimText protected function Trims the field down to the specified length.
FieldPluginBase::RENDER_TEXT_PHASE_COMPLETELY constant Indicator of the renderText() method for rendering the whole element. (if no render_item() method is available).
FieldPluginBase::RENDER_TEXT_PHASE_EMPTY constant Indicator of the renderText() method for rendering the empty text.
FieldPluginBase::RENDER_TEXT_PHASE_SINGLE_ITEM constant Indicator of the renderText() method for rendering a single item. (If no render_item() is present).
FieldPluginBase::submitOptionsForm public function Performs some cleanup tasks on the options array before saving it. Overrides PluginBase::submitOptionsForm 1
FieldPluginBase::theme function Passes values to drupal_render() using $this->themeFunctions() as #theme. Overrides FieldHandlerInterface::theme
FieldPluginBase::themeFunctions public function Provide a full list of possible theme templates used by this style. Overrides PluginBase::themeFunctions
FieldPluginBase::tokenizeValue public function Replaces a value with tokens from the last field. Overrides FieldHandlerInterface::tokenizeValue
FieldPluginBase::trimText public static function Trims the field down to the specified length.
FieldPluginBase::useStringGroupBy public function Determines if this field will be available as an option to group the result by in the style settings. Overrides FieldHandlerInterface::useStringGroupBy
HandlerBase::$actualField public property When a field has been moved this property is set.
HandlerBase::$actualTable public property When a table has been moved this property is set.
HandlerBase::$field public property With field you can override the realField if the real field is not set.
HandlerBase::$moduleHandler protected property The module handler. 3
HandlerBase::$query public property Where the $query object will reside: 7
HandlerBase::$realField public property The actual field in the database table, maybe different on other kind of query plugins/special handlers.
HandlerBase::$relationship public property The relationship used for this field.
HandlerBase::$table public property The table this handler is attached to.
HandlerBase::$tableAlias public property The alias of the table of this handler which is used in the query.
HandlerBase::$viewsData protected property The views data service.
HandlerBase::acceptExposedInput public function Take input from exposed handlers and assign to this handler, if necessary. 1
HandlerBase::breakString public static function Breaks x,y,z and x+y+z into an array. Overrides ViewsHandlerInterface::breakString
HandlerBase::broken public function Determines if the handler is considered 'broken', meaning it's a a placeholder used when a handler can't be found. Overrides ViewsHandlerInterface::broken
HandlerBase::buildExposedForm public function Render our chunk of the exposed handler form when selecting 1
HandlerBase::buildExposeForm public function Form for exposed handler options. 2
HandlerBase::buildExtraOptionsForm public function Provide a form for setting options. 1
HandlerBase::canExpose public function Determine if a handler can be exposed. 2
HandlerBase::caseTransform protected function Transform a string by a certain method.
HandlerBase::defaultExposeOptions public function Set new exposed option defaults when exposed setting is flipped on. 2
HandlerBase::defineExtraOptions public function Provide defaults for the handler.
HandlerBase::displayExposedForm public function Displays the Expose form.
HandlerBase::ensureMyTable public function Ensure the main table for this handler is in the query. This is used a lot. Overrides ViewsHandlerInterface::ensureMyTable 2
HandlerBase::exposedInfo public function Get information about the exposed form for the form renderer. 1
HandlerBase::getDateField public function Creates cross-database SQL dates. 2
HandlerBase::getDateFormat public function Creates cross-database SQL date formatting. 2
HandlerBase::getEntityType public function Determines the entity type used by this handler. Overrides ViewsHandlerInterface::getEntityType
HandlerBase::getField public function Shortcut to get a handler's raw field value. Overrides ViewsHandlerInterface::getField
HandlerBase::getJoin public function Get the join object that should be used for this handler. Overrides ViewsHandlerInterface::getJoin
HandlerBase::getModuleHandler protected function Gets the module handler.
HandlerBase::getTableJoin public static function Fetches a handler to join one table to a primary table from the data cache. Overrides ViewsHandlerInterface::getTableJoin
HandlerBase::getViewsData protected function Gets views data service.
HandlerBase::hasExtraOptions public function If a handler has 'extra options' it will get a little settings widget and another form called extra_options. 1
HandlerBase::isAGroup public function Returns TRUE if the exposed filter works like a grouped filter. 1
HandlerBase::isExposed public function Determine if this item is 'exposed', meaning it provides form elements to let users modify the view.
HandlerBase::multipleExposedInput public function Define if the exposed input has to be submitted multiple times. This is TRUE when exposed filters grouped are using checkboxes as widgets. 1
HandlerBase::placeholder protected function Provides a unique placeholders for handlers.
HandlerBase::postExecute public function Run after the view is executed, before the result is cached. Overrides ViewsHandlerInterface::postExecute
HandlerBase::preQuery public function Run before the view is built. Overrides ViewsHandlerInterface::preQuery 1
HandlerBase::sanitizeValue public function Sanitize the value for output. Overrides ViewsHandlerInterface::sanitizeValue
HandlerBase::setModuleHandler public function Sets the module handler.
HandlerBase::setRelationship public function Called just prior to query(), this lets a handler set up any relationship it needs. Overrides ViewsHandlerInterface::setRelationship
HandlerBase::setViewsData public function
HandlerBase::showExposeButton public function Shortcut to display the expose/hide button. 2
HandlerBase::showExposeForm public function Shortcut to display the exposed options form. Overrides ViewsHandlerInterface::showExposeForm
HandlerBase::storeExposedInput public function If set to remember exposed input in the session, store it there. 1
HandlerBase::submitExposed public function Submit the exposed handler form
HandlerBase::submitExposeForm public function Perform any necessary changes to the form exposes prior to storage. There is no need for this function to actually store the data.
HandlerBase::submitExtraOptionsForm public function Perform any necessary changes to the form values prior to storage. There is no need for this function to actually store the data.
HandlerBase::submitTemporaryForm public function A submit handler that is used for storing temporary items when using multi-step changes, such as ajax requests.
HandlerBase::usesGroupBy public function Provides the handler some groupby. 12
HandlerBase::validate public function Validate that the plugin is correct and can be saved. Overrides PluginBase::validate 2
HandlerBase::validateExposed public function Validate the exposed handler form 4
HandlerBase::validateExposeForm public function Validate the options form. 1
HandlerBase::validateExtraOptionsForm public function Validate the options form.
PluginBase::$configuration protected property Configuration information passed into the plugin. 2
PluginBase::$definition public property Plugins's definition
PluginBase::$displayHandler public property The display object this plugin is for.
PluginBase::$options public property Options for this plugin will be held here.
PluginBase::$pluginDefinition protected property The plugin implementation definition.
PluginBase::$pluginId protected property The plugin_id.
PluginBase::$usesOptions protected property Denotes whether the plugin has an additional options form. 8
PluginBase::$view public property The top object of a view. 1
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::destroy public function Clears a plugin. Overrides ViewsPluginInterface::destroy 2
PluginBase::doFilterByDefinedOptions protected function Do the work to filter out stored options depending on the defined options.
PluginBase::filterByDefinedOptions public function Filter out stored options depending on the defined options. Overrides ViewsPluginInterface::filterByDefinedOptions
PluginBase::getAvailableGlobalTokens public function Returns an array of available token replacements. Overrides ViewsPluginInterface::getAvailableGlobalTokens
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::getProvider public function Returns the plugin provider. Overrides ViewsPluginInterface::getProvider
PluginBase::globalTokenForm public function Adds elements for available core tokens to a form. Overrides ViewsPluginInterface::globalTokenForm
PluginBase::globalTokenReplace public function Returns a string with any core tokens replaced. Overrides ViewsPluginInterface::globalTokenReplace
PluginBase::INCLUDE_ENTITY constant Include entity row languages when listing languages.
PluginBase::INCLUDE_NEGOTIATED constant Include negotiated languages when listing languages.
PluginBase::listLanguages protected function Makes an array of languages, optionally including special languages.
PluginBase::pluginTitle public function Return the human readable name of the display. Overrides ViewsPluginInterface::pluginTitle
PluginBase::preRenderAddFieldsetMarkup public static function Moves form elements into fieldsets for presentation purposes. Overrides ViewsPluginInterface::preRenderAddFieldsetMarkup
PluginBase::preRenderFlattenData public static function Flattens the structure of form elements. Overrides ViewsPluginInterface::preRenderFlattenData
PluginBase::queryLanguageSubstitutions public static function Returns substitutions for Views queries for languages.
PluginBase::setOptionDefaults protected function Fills up the options of the plugin with defaults.
PluginBase::summaryTitle public function Returns the summary of the settings in the display. Overrides ViewsPluginInterface::summaryTitle 6
PluginBase::unpackOptions public function Unpack options over our existing defaults, drilling down into arrays so that defaults don't get totally blown away. Overrides ViewsPluginInterface::unpackOptions
PluginBase::usesOptions public function Returns the usesOptions property. Overrides ViewsPluginInterface::usesOptions 8
PluginBase::validateOptionsForm public function Validate the options form. Overrides ViewsPluginInterface::validateOptionsForm 15
PluginBase::viewsTokenReplace protected function Replaces Views' tokens in a given string. The resulting string will be sanitized with Xss::filterAdmin. 1
PluginBase::VIEWS_QUERY_LANGUAGE_SITE_DEFAULT constant Query string to indicate the site default language.
StringTranslationTrait::$stringTranslation protected property The string translation service.
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.