function InOperator::adminSummary

Same name and namespace in other branches
  1. 8.9.x core/modules/views/src/Plugin/views/filter/InOperator.php \Drupal\views\Plugin\views\filter\InOperator::adminSummary()
  2. 10 core/modules/views/src/Plugin/views/filter/InOperator.php \Drupal\views\Plugin\views\filter\InOperator::adminSummary()
  3. 11.x core/modules/views/src/Plugin/views/filter/InOperator.php \Drupal\views\Plugin\views\filter\InOperator::adminSummary()

Overrides FilterPluginBase::adminSummary

2 calls to InOperator::adminSummary()
Name::adminSummary in core/modules/user/src/Plugin/views/filter/Name.php
Display the filter on the administrative summary.
TaxonomyIndexTid::adminSummary in core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
Display the filter on the administrative summary.
2 methods override InOperator::adminSummary()
Name::adminSummary in core/modules/user/src/Plugin/views/filter/Name.php
Display the filter on the administrative summary.
TaxonomyIndexTid::adminSummary in core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
Display the filter on the administrative summary.

File

core/modules/views/src/Plugin/views/filter/InOperator.php, line 327

Class

InOperator
Simple filter to handle matching of multiple options selectable via checkboxes.

Namespace

Drupal\views\Plugin\views\filter

Code

public function adminSummary() {
    if ($this->isAGroup()) {
        return $this->t('grouped');
    }
    if (!empty($this->options['exposed'])) {
        return $this->t('exposed');
    }
    $info = $this->operators();
    $this->getValueOptions();
    // Some filter_in_operator usage uses optgroups forms, so flatten it.
    $flat_options = OptGroup::flattenOptions($this->valueOptions);
    if (!is_array($this->value)) {
        return;
    }
    $operator = $info[$this->operator]['short'];
    $values = '';
    if (in_array($this->operator, $this->operatorValues(1))) {
        // Remove every element which is not known.
        foreach ($this->value as $value) {
            if (!isset($flat_options[$value])) {
                unset($this->value[$value]);
            }
        }
        // Choose different kind of output for 0, a single and multiple values.
        if (count($this->value) == 0) {
            $values = $this->t('Unknown');
        }
        elseif (count($this->value) == 1) {
            // If any, use the 'single' short name of the operator instead.
            if (isset($info[$this->operator]['short_single'])) {
                $operator = $info[$this->operator]['short_single'];
            }
            $keys = $this->value;
            $value = array_shift($keys);
            if (isset($flat_options[$value])) {
                $values = $flat_options[$value];
            }
            else {
                $values = '';
            }
        }
        else {
            foreach ($this->value as $value) {
                if ($values !== '') {
                    $values .= ', ';
                }
                if (mb_strlen($values) > 8) {
                    $values = Unicode::truncate($values, 8, FALSE, TRUE);
                    break;
                }
                if (isset($flat_options[$value])) {
                    $values .= $flat_options[$value];
                }
            }
        }
    }
    return $operator . ($values !== '' ? ' ' . $values : '');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.