Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. EntityField.php

function EntityField::init

Overrides FieldPluginBase::init

File

core/modules/views/src/Plugin/views/field/EntityField.php, line 213

Class

EntityField
A field that displays entity field data.

Namespace

Drupal\views\Plugin\views\field

Code

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;
        }
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal